From 0f1135d5d623ff64fb0922557e2f8cc62ad2749a Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 9 Aug 2019 14:07:04 -0500 Subject: [PATCH 01/44] adding background color to settings and related infrastruture --- .../spark/view/Controls/DIYGrid/DIYGrid.cs | 1 + .../Controls/DIYGrid/Settings/GridSettings.cs | 26 ++++++++++++++----- .../DIYGrid/Settings/GridSettingsManager.cs | 6 +++-- .../DIYGrid/Settings/GridSettingsVM.cs | 4 ++- .../Settings/SimpleGridSettingsManager.cs | 6 +++-- .../DIYGrid/Settings/SimpleGridSettingsVM.cs | 5 +++- .../Shell/Settings/ShellSettingsDialog.xaml | 8 ++++-- 7 files changed, 42 insertions(+), 14 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs index fda5d6cc6..813a9ac31 100644 --- a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs +++ b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs @@ -247,6 +247,7 @@ namespace mbts.ui.controls { // and FrameworkElementColumns that paint the selection brush themselves // (e.g MarketView bid/ask columns, bc their background is not transparent, it covers the ListBoxItem selection-highlight). public static readonly SolidColorBrush DefaultSelectionHighlight = new SolidColorBrush(Colors.MediumSlateBlue) { Opacity = 0.4 }; + public static readonly SolidColorBrush DefaultBackgroundColor = new SolidColorBrush(BTSColors.Grid.input_cell_background) { Opacity = 0.40 }; public static readonly Pen DefaultSelectionStroke = new Pen(Brushes.MediumSlateBlue, 1); readonly NotifyCollectionChangedEventHandler _sort_descriptions_collection_changed_cb; double _inactive_selection_opacity = 0.2; diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs index a46c203e3..ac0ddef91 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs @@ -19,7 +19,9 @@ namespace mbts.ui.settings { const ushort _default_font_weight = 400; public static GridSettings Default => - new GridSettings(selection_highlight: new ColorOpacityProto(FallbackValues.selection_highlight.Color, FallbackValues.selection_highlight.Opacity)); + new GridSettings( + selection_highlight: new ColorOpacityProto(FallbackValues.selection_highlight.Color, FallbackValues.selection_highlight.Opacity), + background_color: new ColorOpacityProto(FallbackValues.background_color.Color, FallbackValues.background_color.Opacity)); // corrects any inappropriate values that would render the grid unusable (usually nulls) // NOTE: if you add a property to GridSettings that could have such a value, please add a conditional-correction for it below) @@ -39,6 +41,7 @@ namespace mbts.ui.settings { public static Color font_color => _default_font_color.rgb_color(); public static FontWeight font_weight => FontWeight.FromOpenTypeWeight(_default_font_weight); public static SolidColorBrush selection_highlight => DIYGrid.DefaultSelectionHighlight; + public static SolidColorBrush background_color => DIYGrid.DefaultBackgroundColor; } public static IValueConverter selection_highlight_converter => ValueConverter.create(gs => gs.selection_highlight.to_brush().frozen()); @@ -65,17 +68,22 @@ namespace mbts.ui.settings { List _columns; [ProtoMember(7)] List _sorting_criterion; + [ProtoMember(8)] + readonly ColorOpacityProto _background_color; public GridSettings() { _font_family = _default_font_family; _font_size = _default_font_size; _font_weight = _default_font_weight; _font_color = _default_font_color; + + // new setting in proto defaulted here + _background_color = new ColorOpacityProto(DIYGrid.DefaultBackgroundColor.Color, DIYGrid.DefaultBackgroundColor.Opacity); } public GridSettings( string font_family = _default_font_family, double font_size = _default_font_size, FontWeight font_weight = default, uint font_color = _default_font_color, - ColorOpacityProto? selection_highlight = null, IEnumerable columns = null, IEnumerable sorting_criterion = null) { + ColorOpacityProto? selection_highlight = null, IEnumerable columns = null, IEnumerable sorting_criterion = null, ColorOpacityProto? background_color = null) { // _font_family = font_family; _font_size = font_size; @@ -84,6 +92,7 @@ namespace mbts.ui.settings { _selection_highlight = selection_highlight ?? new ColorOpacityProto(0, 1); _columns = new List(columns.empty_if_null()); _sorting_criterion = new List(sorting_criterion.empty_if_null()); + _background_color = background_color ?? new ColorOpacityProto(DIYGrid.DefaultBackgroundColor.Color, DIYGrid.DefaultBackgroundColor.Opacity); } public string font_family => _font_family; @@ -91,12 +100,14 @@ namespace mbts.ui.settings { public uint font_color => _font_color; public FontWeight font_weight => FontWeight.FromOpenTypeWeight(_font_weight); public ColorOpacityProto selection_highlight => _selection_highlight; + public ColorOpacityProto background_color => _background_color; public IReadOnlyList columns => _columns ?? (_columns = new List(0)); [Obsolete] // TODO: remove sorting_criterion from GridSettings entirely. This should be part of IShellWindow's StartupData, since it is an instance-specific setting, and prob not part of the shared defaults public IReadOnlyList sorting_criterion => _sorting_criterion ?? (_sorting_criterion = new List(0)); public static GridSettings get_default() => - new GridSettings(_default_font_family, _default_font_size, FontWeights.Normal, _default_font_color, new ColorOpacityProto(Colors.MediumSlateBlue, 0.4)); + new GridSettings(_default_font_family, _default_font_size, FontWeights.Normal, _default_font_color, new ColorOpacityProto(DIYGrid.DefaultSelectionHighlight.Color, DIYGrid.DefaultSelectionHighlight.Opacity), + background_color: new ColorOpacityProto(DIYGrid.DefaultBackgroundColor.Color, DIYGrid.DefaultBackgroundColor.Opacity)); public GridSettings with(IEnumerable columns = null, IEnumerable sorting_criterion = null, string font_family = null, double font_size = double.NaN) => new GridSettings( @@ -106,7 +117,8 @@ namespace mbts.ui.settings { _font_color, _selection_highlight, columns ?? _columns, - sorting_criterion ?? _sorting_criterion); + sorting_criterion ?? _sorting_criterion, + _background_color); public GridSettings clone() => with(); @@ -119,8 +131,9 @@ namespace mbts.ui.settings { selection_highlight == other.selection_highlight && EqualityComparer.safe_sequence_equals(columns, other.columns) && #pragma warning disable CS0612 // Type or member is obsolete - EqualityComparer.safe_sequence_equals(sorting_criterion, other.sorting_criterion); + EqualityComparer.safe_sequence_equals(sorting_criterion, other.sorting_criterion) && #pragma warning restore CS0612 // Type or member is obsolete + background_color == other.background_color; public override bool Equals(object obj) => Equals(obj as GridSettings); @@ -134,7 +147,8 @@ namespace mbts.ui.settings { selection_highlight.GetHashCode(), EqualityComparer.safe_aggregate_hash(columns), #pragma warning disable CS0612 // Type or member is obsolete - EqualityComparer.safe_aggregate_hash(sorting_criterion)); + EqualityComparer.safe_aggregate_hash(sorting_criterion), #pragma warning restore CS0612 // Type or member is obsolete + background_color.GetHashCode()); } } \ No newline at end of file diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs index 11dc2d487..eed7af4cd 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs @@ -30,7 +30,7 @@ namespace mbts.ui { readonly DelegateProperty _font_family; readonly DelegateProperty _font_weight; readonly DelegateProperty _font_size; - readonly DelegateProperty _font_color, _selection_highlight; + readonly DelegateProperty _font_color, _selection_highlight, _background_color; readonly SetMap, AnimationDefinitionWrapper> _animation_defs = new SetMap, AnimationDefinitionWrapper>(); readonly Func _predicate_data_factory; readonly Func> _predicate_factory; @@ -77,6 +77,7 @@ namespace mbts.ui { _font_size = backing(nameof(font_size), () => grid_settings.font_size, nameof(font_size)); _font_color = backing(nameof(font_color), () => grid_settings.font_color.rgb_solid_brush().frozen(), nameof(grid_settings)); _selection_highlight = backing(nameof(selection_highlight), () => grid_settings.selection_highlight.to_brush().frozen(), nameof(grid_settings)); + _background_color = backing(nameof(background_color), () => grid_settings.background_color.to_brush().frozen(), nameof(grid_settings)); } public void Dispose() => @@ -88,6 +89,7 @@ namespace mbts.ui { public double font_size => _font_size.Value; public SolidColorBrush font_color => _font_color.Value; public SolidColorBrush selection_highlight => _selection_highlight.Value; + public SolidColorBrush background_color => _background_color.Value; public GridSettingsVM create_vm(GridSettings settings) { var vm = new GridSettingsVM(_bus, _orders_model, _predicate_data_factory, _notification_predicate_factory, _create_predicate_vm, _create_column_predicate_vm, _create_settings_obj, _column_flags.ToDictionary(kv => kv.Key, kv => kv.Value.flags)); @@ -112,7 +114,7 @@ namespace mbts.ui { var grid = value.general ?? GridSettings.Default; _grid_settings.set(grid); foreach (ColumnBase col in _columns) - col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight); + col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color); _predicate_animations_data = value.predicate_animations; _animation_defs.clear(); foreach (var pa in _predicate_animations_data) { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs index 175940d56..8caeebfff 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs @@ -100,6 +100,7 @@ namespace mbts.spark { public FontWeight font_weight { get => _font_weight.Value; set => _font_weight.set(value); } public ColorPickerPopupVM font_color { get; } = new ColorPickerPopupVM(); public ColorPickerPopupVM selection_highlight { get; } = new ColorPickerPopupVM(); + public ColorPickerPopupVM background_color { get; } = new ColorPickerPopupVM(); public double font_size { get => _font_size.Value; set => _font_size.set(value); } public bool enable_sound_triggers => true; public bool show_predicate_animations { get => _show_predicate_animations.Value; set => _show_predicate_animations.set(value); } @@ -130,7 +131,7 @@ namespace mbts.spark { foreach (IGrouping g in animations) animation_map.AddOrUpdate(g.Key, p => animation_tuple(c: g), (p, t) => t.cell_animations.AddRange(g)); } - return _create_settings_obj(new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), col_settings), + return _create_settings_obj(new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), col_settings, background_color: background_color.to_proto()), animation_map.Select(kv => PredicateAnimations.create_data(kv.Key, kv.Value.cell_animations, kv.Value.row_animations, kv.Value.sounds))); // (List row_animations, List sounds, List cell_animations) animation_tuple(IEnumerable r = null, IEnumerable s = null, IGrouping c = null) => @@ -142,6 +143,7 @@ namespace mbts.spark { _font_weight.set(sd.general.font_weight); font_color.load_from(sd.general.font_color.rgb_solid_brush()); selection_highlight.load_from(sd.general.selection_highlight.to_brush()); + background_color.load_from(sd.general.background_color.to_brush()); _font_size.set(sd.general.font_size); var col_animations = new Dictionary>>(); predicate_animations.Clear(); diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs index 76823094e..4b66e19f6 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs @@ -20,7 +20,7 @@ namespace mbts.ui { readonly DelegateProperty _font_family; readonly DelegateProperty _font_weight; readonly DelegateProperty _font_size; - readonly DelegateProperty _font_color, _selection_highlight; + readonly DelegateProperty _font_color, _selection_highlight, _background_color; readonly IReadOnlyDictionary _column_flags; public SimpleGridSettingsManager(ObservableCollection columns) @@ -35,6 +35,7 @@ namespace mbts.ui { _font_size = backing(nameof(font_size), () => grid_settings.font_size, nameof(font_size)); _font_color = backing(nameof(font_color), () => grid_settings.font_color.rgb_solid_brush().frozen(), nameof(grid_settings)); _selection_highlight = backing(nameof(selection_highlight), () => grid_settings.selection_highlight.to_brush().frozen(), nameof(grid_settings)); + _background_color = backing(nameof(background_color), () => grid_settings.background_color.to_brush().frozen(), nameof(grid_settings)); _row_vms = row_vms; } @@ -44,6 +45,7 @@ namespace mbts.ui { public double font_size => _font_size.Value; public SolidColorBrush font_color => _font_color.Value; public SolidColorBrush selection_highlight => _selection_highlight.Value; + public SolidColorBrush background_color => _background_color.Value; public SimpleGridSettingsVM create_vm(GridSettings settings) { var vm = new SimpleGridSettingsVM(_column_flags.ToDictionary(kv => kv.Key, kv => kv.Value.flags)); @@ -86,7 +88,7 @@ namespace mbts.ui { grid = grid ?? GridSettings.Default; _grid_settings.set(grid); foreach (ColumnBase col in _columns) - col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight); + col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color); // ** in the unfortunate event that we botch backwards compatability, and the columns don't bear a 1:1 relationship with the column-settings // don't add insult to injury by crashing ** if (grid_settings.columns != null) { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs index c27cce279..220424bc6 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs @@ -79,6 +79,7 @@ namespace mbts.spark { public FontWeight font_weight { get => _font_weight.Value; set => _font_weight.set(value); } public ColorPickerPopupVM font_color { get; } = new ColorPickerPopupVM(); public ColorPickerPopupVM selection_highlight { get; } = new ColorPickerPopupVM(); + public ColorPickerPopupVM background_color { get; } = new ColorPickerPopupVM(); public double font_size { get => _font_size.Value; set => _font_size.set(value); } public bool enable_sound_triggers => false; public bool show_predicate_animations { get => _show_predicate_animations.Value; set => _show_predicate_animations.set(value); } @@ -98,12 +99,13 @@ namespace mbts.spark { get { yield return font_color; yield return selection_highlight; + yield return background_color; yield return this; } } public GridSettings create() => - new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), columns.Select(c => c.create())); + new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), columns.Select(c => c.create()), background_color: background_color.to_proto()); public void load_from(GridSettings value) { if (value == null) @@ -113,6 +115,7 @@ namespace mbts.spark { _font_weight.set(value.font_weight); font_color.load_from(value.font_color.rgb_solid_brush()); selection_highlight.load_from(value.selection_highlight.to_brush()); + background_color.load_from(value.background_color.to_brush()); _font_size.set(value.font_size); var curr_col_id = current_column?.id; columns.SetItems(value.columns.Select(col => { diff --git a/src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml b/src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml index 2173a5f7d..882871751 100644 --- a/src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml +++ b/src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml @@ -49,6 +49,8 @@ + + @@ -69,8 +71,10 @@ Font Color (default) - Selection Highlight - + Background Color (default) + + Selection Highlight + From 19729a276d1050fa24cfa42287fa43277fa4a272 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 9 Aug 2019 14:08:03 -0500 Subject: [PATCH 02/44] adding background color to ColumnBase as every column should be able to eventually override the grid default bg --- .../view/Controls/DIYGrid/Columns/ColumnBase.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs index 3d3e1e1f6..6de340375 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs @@ -1,4 +1,5 @@ -using mbts.spark; +using bts.proto; +using mbts.spark; using mbts.spark.filters; using mbts.ui.settings; using mbts.ui.shell; @@ -173,16 +174,19 @@ namespace mbts.ui.controls { //readonly ExternalProperty _font_weigh FontWeight _fallback_font_weight; Color _fallback_font_color; + ColorOpacityProto _fallback_background_color; double _fallback_font_size; FontFamily _fallback_font_family; FontWeight? _font_weight_override; Color? _font_color_override; + ColorOpacityProto? _background_color_override; object _header_copy; protected ColumnBase() { var gs = GridSettings.Default; _fallback_font_weight = gs.font_weight; _fallback_font_color = gs.font_color.rgb_color(); + _fallback_background_color = gs.background_color; _fallback_font_size = gs.font_size; _fallback_font_family = new FontFamily(gs.font_family); original_width = double.NaN; @@ -215,6 +219,9 @@ namespace mbts.ui.controls { public FontWeight font_weight => font_weight_override ?? _fallback_font_weight; public Color font_color => font_color_override ?? _fallback_font_color; public Brush font_brush => new SolidColorBrush(font_color); + public ColorOpacityProto? background_color_override { get => _background_color_override; set => _set_font_param(ref _background_color_override, value); } + public ColorOpacityProto background_color => background_color_override ?? _fallback_background_color; + public Brush background_brush => background_color.to_brush(); // TODO: find a better way to store the header-property in a thread-safe manner - a value for GridSettings.display_name, more specifically. // Since save_state is called from a different thread in IShared/SlowWindows, it is not safe to access the DependencyProperty store from that method. // By updating a local _header_copy field in the Header setter, the DependencyProperty lookup may be bypassed when appropriate (see create method below). @@ -235,7 +242,7 @@ namespace mbts.ui.controls { if (settings == null) return; using (ReflectionHelper.detect_property_changes(this, _raise_prop_changed, nameof(is_visible), nameof(is_collapsed), nameof(font_weight_override), nameof(font_weight), - nameof(font_color_override), nameof(font_color), nameof(font_brush), nameof(font_family), nameof(font_size), nameof(horizontal_alignment), nameof(horizontal_offset))) { + nameof(font_color_override), nameof(font_color), nameof(font_brush), nameof(font_family), nameof(font_size), nameof(horizontal_alignment), nameof(horizontal_offset), nameof(background_color), nameof(background_brush), nameof(background_color_override))) { // id = settings.id; if (!string.IsNullOrEmpty(settings.display_name)) @@ -246,6 +253,7 @@ namespace mbts.ui.controls { font_color_override = settings.font_color_override; horizontal_alignment = settings.horizontal_alignment; horizontal_offset = settings.horizontal_offset; + //background_color_override = settings.background_color_override; } if (original_width != settings.width) { original_width = settings.width; @@ -255,11 +263,12 @@ namespace mbts.ui.controls { } // 'fallback' font-params (aka 'grid-level' font-params) - public void set_fallback_font_params(FontFamily font_family, double font_size, Color font_color, FontWeight font_weight) { - using (ReflectionHelper.detect_property_changes(this, _raise_prop_changed, nameof(font_family), nameof(font_size), nameof(font_color), nameof(font_weight))) { + public void set_fallback_font_params(FontFamily font_family, double font_size, Color font_color, FontWeight font_weight, ColorOpacityProto background_color) { + using (ReflectionHelper.detect_property_changes(this, _raise_prop_changed, nameof(font_family), nameof(font_size), nameof(font_color), nameof(font_weight), nameof(background_color), nameof(background_brush))) { _fallback_font_family = font_family; _fallback_font_size = font_size; _fallback_font_color = font_color; + _fallback_background_color = background_color; _fallback_font_weight = font_weight; } font_params_changed?.Invoke(); From 14a86d7b29365268d838a752d8db33a190279bb6 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 9 Aug 2019 14:09:19 -0500 Subject: [PATCH 03/44] changing RenderColumn to use ColumnBase's background_brush; removed background property --- src/client/spark/view/Controls/DIYGrid/Columns/RenderColumn.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/RenderColumn.cs b/src/client/spark/view/Controls/DIYGrid/Columns/RenderColumn.cs index 4c58bc40d..f5779e1e5 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/RenderColumn.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/RenderColumn.cs @@ -30,7 +30,7 @@ namespace mbts.ui.controls { Func get_brush = null) : base() { _get_text = get_text; - Func get_default_background_brush = (TRowVM _) => this.background; + Func get_default_background_brush = (TRowVM _) => this.background_brush; _get_background_brush = get_brush ?? get_default_background_brush; this.filter = filter; this.filter_template = filter_template; @@ -42,7 +42,6 @@ namespace mbts.ui.controls { public IDataGridColumnFilter filter { get; } public string filter_template { get; } - public Brush background { get; set; } public VerticalAlignment vertical_alignment { get; set; } = VerticalAlignment.Center; public Thickness padding { get; set; } = DefaultCellPadding; public GlyphContext glyph_context { get; private set; } From a14d449b33927e915668f7a313ef06f7add12ad7 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 9 Aug 2019 15:06:25 -0500 Subject: [PATCH 04/44] this brush needs to be frozen, because of course it does --- src/client/spark/view/Controls/DIYGrid/DIYGrid.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs index 813a9ac31..7b32426c3 100644 --- a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs +++ b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs @@ -247,7 +247,8 @@ namespace mbts.ui.controls { // and FrameworkElementColumns that paint the selection brush themselves // (e.g MarketView bid/ask columns, bc their background is not transparent, it covers the ListBoxItem selection-highlight). public static readonly SolidColorBrush DefaultSelectionHighlight = new SolidColorBrush(Colors.MediumSlateBlue) { Opacity = 0.4 }; - public static readonly SolidColorBrush DefaultBackgroundColor = new SolidColorBrush(BTSColors.Grid.input_cell_background) { Opacity = 0.40 }; + // I have no idea why DefaultBackgroundColor needs to be frozen but DefaultSelectionHighlight is apparently fine as is + public static readonly SolidColorBrush DefaultBackgroundColor = new SolidColorBrush(BTSColors.Grid.input_cell_background) { Opacity = 0.40 }.frozen(); public static readonly Pen DefaultSelectionStroke = new Pen(Brushes.MediumSlateBlue, 1); readonly NotifyCollectionChangedEventHandler _sort_descriptions_collection_changed_cb; double _inactive_selection_opacity = 0.2; From d6499464cf9637f8aad0ba7fdca954792ed413bb Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Mon, 12 Aug 2019 13:01:34 -0500 Subject: [PATCH 05/44] fleshing out per Column bg color override --- .../data/Proto/NullableColorOpacityProto.cs | 45 +++++++++++++++++++ .../Controls/DIYGrid/Columns/ColumnBase.cs | 6 +-- .../DIYGrid/Settings/GridColumnSettings.cs | 18 +++++--- .../DIYGrid/Settings/GridColumnSettingsVM.cs | 26 +++++++++-- .../DIYGrid/Settings/GridSettingsView.xaml | 10 +++++ .../Settings/ImmutableColumnSettingsStore.cs | 16 +++++++ .../Settings/SimpleGridColumnSettingsVM.cs | 24 +++++++++- 7 files changed, 132 insertions(+), 13 deletions(-) create mode 100644 src/client/spark/core/data/Proto/NullableColorOpacityProto.cs diff --git a/src/client/spark/core/data/Proto/NullableColorOpacityProto.cs b/src/client/spark/core/data/Proto/NullableColorOpacityProto.cs new file mode 100644 index 000000000..77344d6a3 --- /dev/null +++ b/src/client/spark/core/data/Proto/NullableColorOpacityProto.cs @@ -0,0 +1,45 @@ +using bts.utils; +using mbts.ui; +using mbts.utils; +using ProtoBuf; +using System; +using System.Windows.Media; + +namespace bts.proto { + [ProtoContract] + struct NullableColorOpacityProto : IEquatable { + [ProtoMember(1)] + readonly uint? _color; + [ProtoMember(2)] + readonly double? _opacity; + + public NullableColorOpacityProto(ColorOpacityProto? cop = default) { + _color = cop?.color.rgb_color(); + _opacity = cop?.opacity; + } + + public ColorOpacityProto? value { + get { + if (_color.HasValue && _opacity.HasValue) + return new ColorOpacityProto(_color.Value, _opacity.Value); + return null; + } + } + + public bool Equals(NullableColorOpacityProto other) => + EqualityComparer.nullable_equals(_color, other._color) && + EqualityComparer.nullable_equals(_opacity, other._opacity); + + public override bool Equals(object obj) => + obj is NullableColorProto ncp && Equals(ncp); + + public override int GetHashCode() { + uint c = _color.HasValue ? _color.Value : 0; + double o = _opacity.HasValue ? _opacity.Value : 0; + return EqualityComparer.aggregate_hash(c, o); + } + + public static bool operator ==(NullableColorOpacityProto a, NullableColorOpacityProto b) => a.Equals(b); + public static bool operator !=(NullableColorOpacityProto a, NullableColorOpacityProto b) => !a.Equals(b); + } +} \ No newline at end of file diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs index 6de340375..6bbaabe2c 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs @@ -231,7 +231,7 @@ namespace mbts.ui.controls { } public GridColumnSettings create() => - new GridColumnSettings(id, _header_copy?.ToString(), is_visible, is_collapsed, font_weight_override, font_color_override, ActualWidth, horizontal_alignment, horizontal_offset); + new GridColumnSettings(id, _header_copy?.ToString(), is_visible, is_collapsed, font_weight_override, font_color_override, ActualWidth, horizontal_alignment, horizontal_offset, background_color_override); void _set_font_param(ref T field, T value) { field = value; @@ -242,7 +242,7 @@ namespace mbts.ui.controls { if (settings == null) return; using (ReflectionHelper.detect_property_changes(this, _raise_prop_changed, nameof(is_visible), nameof(is_collapsed), nameof(font_weight_override), nameof(font_weight), - nameof(font_color_override), nameof(font_color), nameof(font_brush), nameof(font_family), nameof(font_size), nameof(horizontal_alignment), nameof(horizontal_offset), nameof(background_color), nameof(background_brush), nameof(background_color_override))) { + nameof(font_color_override), nameof(font_color), nameof(font_brush), nameof(font_family), nameof(font_size), nameof(horizontal_alignment), nameof(horizontal_offset), nameof(background_color_override), nameof(background_color), nameof(background_brush))) { // id = settings.id; if (!string.IsNullOrEmpty(settings.display_name)) @@ -253,7 +253,7 @@ namespace mbts.ui.controls { font_color_override = settings.font_color_override; horizontal_alignment = settings.horizontal_alignment; horizontal_offset = settings.horizontal_offset; - //background_color_override = settings.background_color_override; + background_color_override = settings.background_color_override; } if (original_width != settings.width) { original_width = settings.width; diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs index cce3f9388..73650567a 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs @@ -60,6 +60,9 @@ namespace mbts.ui.settings { [DefaultValue(_default_horizontal_offset)] readonly double _horizontal_offset; + [ProtoMember(10)] + readonly NullableColorOpacityProto _background_color_override; + public GridColumnSettings() { _is_visible = _default_is_visible; _is_collapsed = _default_is_collapsed; @@ -69,7 +72,7 @@ namespace mbts.ui.settings { } public GridColumnSettings(string id, string display_name = null, bool is_visible = _default_is_visible, bool is_collapsed = _default_is_collapsed, FontWeight? font_weight_override = null, Color? font_color_override = null, - double width = _default_width, HorizontalAlignment horizontal_alignment = _default_horizontal_alignment, double horizontal_offset = _default_horizontal_offset) { + double width = _default_width, HorizontalAlignment horizontal_alignment = _default_horizontal_alignment, double horizontal_offset = _default_horizontal_offset, ColorOpacityProto? background_color_override = null) { _id = id; _display_name = display_name; _is_visible = is_visible; @@ -79,6 +82,7 @@ namespace mbts.ui.settings { _width = width; _horizontal_alignment = horizontal_alignment; _horizontal_offset = horizontal_offset; + _background_color_override = new NullableColorOpacityProto(background_color_override); } public string id => _id; @@ -90,10 +94,11 @@ namespace mbts.ui.settings { public HorizontalAlignment horizontal_alignment => _horizontal_alignment; public double horizontal_offset => _horizontal_offset; public string display_name => _display_name; + public ColorOpacityProto? background_color_override => _background_color_override.value; public GridColumnSettings with( string display_name = null, bool? is_visible = null, bool? is_collapsed = null, NullableFontWeightProto? font_weight_override = null, NullableColorProto? font_color_override = null, - double? width = null, HorizontalAlignment? horizontal_alignment = null, double? horizontal_offset = null) => + double? width = null, HorizontalAlignment? horizontal_alignment = null, double? horizontal_offset = null, NullableColorOpacityProto? background_color_override = null) => // new GridColumnSettings(_id, display_name ?? this.display_name, @@ -103,7 +108,8 @@ namespace mbts.ui.settings { (font_color_override ?? _font_color_override).value, width ?? this.width, horizontal_alignment ?? this.horizontal_alignment, - horizontal_offset ?? this.horizontal_offset); + horizontal_offset ?? this.horizontal_offset, + (background_color_override ?? _background_color_override).value); public bool Equals(GridColumnSettings other) => other != null && @@ -116,7 +122,8 @@ namespace mbts.ui.settings { width == other.width && horizontal_alignment == other.horizontal_alignment && horizontal_offset == other.horizontal_offset && - display_name == other.display_name; + display_name == other.display_name && + background_color_override.Equals(other.background_color_override); public override bool Equals(object obj) => Equals(obj as GridColumnSettings); @@ -132,7 +139,8 @@ namespace mbts.ui.settings { width.GetHashCode(), horizontal_alignment.GetHashCode(), horizontal_offset.GetHashCode(), - display_name.GetHashCode() + display_name.GetHashCode(), + background_color_override.GetHashCode() ); public override string ToString() { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs index c8aac5300..521924964 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs @@ -26,7 +26,8 @@ namespace mbts.spark { None = 0, ImmutableFontColor = 1, ImmutableFontWeight = 1 << 1, - ImmutableHeader = 1 << 2 + ImmutableHeader = 1 << 2, + ImmutableBackgroundColor = 1 << 3 } partial class GridSettingsVM { @@ -50,7 +51,9 @@ namespace mbts.spark { _can_override_font_color = true, _is_font_color_overridden, _can_override_font_weight = true, - _is_font_weight_overridden; + _is_font_weight_overridden, + _can_override_background_color = true, + _is_background_color_overridden; FontWeight _font_weight_override; GridColumnSettings _settings; @@ -78,6 +81,10 @@ namespace mbts.spark { public bool can_override_font_weight { get => _can_override_font_weight; private set => Set(ref _can_override_font_weight, value); } public bool is_font_weight_overridden { get => _is_font_weight_overridden; set => Set(ref _is_font_weight_overridden, value); } public FontWeight font_weight_override { get => _font_weight_override; set => Set(ref _font_weight_override, value); } + // background color override + public bool can_override_background_color { get => _can_override_background_color; private set => Set(ref _can_override_background_color, value); } + public bool is_background_color_overridden { get => _is_background_color_overridden; set => Set(ref _is_background_color_overridden, value); } + public ColorPickerPopupVM background_color_override { get; } = new ColorPickerPopupVM(); // animations public ObservableEditableCollection predicate_animations { get; } @@ -89,7 +96,10 @@ namespace mbts.spark { is_font_weight_overridden ? new NullableFontWeightProto(font_weight_override) : default, is_font_color_overridden ? new NullableColorProto(font_color_override.color) : default, width, - horizontal_alignment); + horizontal_alignment, + background_color_override: is_background_color_overridden ? + new NullableColorOpacityProto(new ColorOpacityProto(background_color_override.color, background_color_override.opacity)) + : default); var animations_lookup = predicate_animations.ToFlatLookup(pa => pa.predicate.create_assigned(owner._predicate_data_factory), pa => pa.animations.Select(a => a.create())); return (settings, animations_lookup); } @@ -111,6 +121,13 @@ namespace mbts.spark { if (is_font_weight_overridden) { _font_weight_override = _settings.font_weight_override.Value; } + // background color + is_background_color_overridden = _settings.background_color_override.HasValue; + if (is_background_color_overridden) { + background_color_override.load_from( + new SolidColorBrush(_settings.background_color_override.Value.color) { + Opacity = _settings.background_color_override.Value.opacity }); + } predicate_animations.SetItems(value.animations.empty_if_null().Select(g => { var vm = new PredicateCellAnimationVM(id, owner._create_column_predicate_vm(id), owner._predicate_data_factory); vm.load_from((g.Key, g)); @@ -129,6 +146,9 @@ namespace mbts.spark { // font weight can_override_font_weight = (flags & GridColumnSettingsFeatureFlags.ImmutableFontWeight) == 0; is_font_weight_overridden &= can_override_font_weight; + // background color + can_override_background_color = (flags & GridColumnSettingsFeatureFlags.ImmutableBackgroundColor) == 0; + is_background_color_overridden &= can_override_background_color; } public override string ToString() => $"{display_name} ({id})"; diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml index a9dd99c68..e525965b0 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml @@ -642,6 +642,8 @@ + + @@ -672,6 +674,14 @@ Visibility="{Binding DataContext.current_column.is_font_color_overridden, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource AncestorType=usp:GridSettingsView}}" /> + Override Background Color + + diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/ImmutableColumnSettingsStore.cs b/src/client/spark/view/Controls/DIYGrid/Settings/ImmutableColumnSettingsStore.cs index 4ab50812d..01503387f 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/ImmutableColumnSettingsStore.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/ImmutableColumnSettingsStore.cs @@ -21,6 +21,9 @@ namespace mbts.ui { if ((flags & GridColumnSettingsFeatureFlags.ImmutableFontWeight) != 0) { stores_per_flag.Add(new ImmutableFontWeightOverrideStore()); } + if ((flags & GridColumnSettingsFeatureFlags.ImmutableBackgroundColor) != 0) { + stores_per_flag.Add(new ImmutableBackgroundColorOverrideStore()); + } return new CompositeImmutableSettingsStore(stores_per_flag, flags); } @@ -66,6 +69,19 @@ namespace mbts.ui { _value = new NullableFontWeightProto(settings.font_weight_override); } + class ImmutableBackgroundColorOverrideStore : ImmutableColumnSettingStore { + NullableColorOpacityProto _value; + + public ImmutableBackgroundColorOverrideStore() + : base(GridColumnSettingsFeatureFlags.ImmutableBackgroundColor) { } + + public override GridColumnSettings apply(GridColumnSettings settings) => + settings.with(background_color_override: _value); + + public override void store(GridColumnSettings settings) => + _value = new NullableColorOpacityProto(settings.background_color_override); + } + class CompositeImmutableSettingsStore : ImmutableColumnSettingStore { readonly IReadOnlyList _stores; public CompositeImmutableSettingsStore(IReadOnlyList stores, GridColumnSettingsFeatureFlags flags) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs index 407f5b2d4..d4dc86c50 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs @@ -21,7 +21,9 @@ namespace mbts.spark { _can_override_font_color = true, _is_font_color_overridden, _can_override_font_weight = true, - _is_font_weight_overridden; + _is_font_weight_overridden, + _can_override_background_color = true, + _is_background_color_overridden; FontWeight _font_weight_override; GridColumnSettings _settings; @@ -43,6 +45,10 @@ namespace mbts.spark { public bool can_override_font_weight { get => _can_override_font_weight; private set => Set(ref _can_override_font_weight, value); } public bool is_font_weight_overridden { get => _is_font_weight_overridden; set => Set(ref _is_font_weight_overridden, value); } public FontWeight font_weight_override { get => _font_weight_override; set => Set(ref _font_weight_override, value); } + // background color override + public bool can_override_background_color { get => _can_override_background_color; private set => Set(ref _can_override_background_color, value); } + public bool is_background_color_overridden { get => _is_background_color_overridden; set => Set(ref _is_background_color_overridden, value); } + public ColorPickerPopupVM background_color_override { get; } = new ColorPickerPopupVM(); public GridColumnSettings create() => _settings.with( @@ -52,7 +58,10 @@ namespace mbts.spark { is_font_weight_overridden ? new NullableFontWeightProto(font_weight_override) : (NullableFontWeightProto?)null, is_font_color_overridden ? new NullableColorProto(font_color_override.color) : (NullableColorProto?)null, width, - horizontal_alignment); + horizontal_alignment, + background_color_override: is_background_color_overridden ? + new NullableColorOpacityProto(new ColorOpacityProto(background_color_override.color, background_color_override.opacity)) + : default); public void load_from(GridColumnSettings value) { _settings = value; @@ -71,6 +80,14 @@ namespace mbts.spark { if (is_font_weight_overridden) { _font_weight_override = _settings.font_weight_override.Value; } + // background color + is_background_color_overridden = _settings.background_color_override.HasValue; + if (is_background_color_overridden) { + background_color_override.load_from( + new SolidColorBrush(_settings.background_color_override.Value.color) { + Opacity = _settings.background_color_override.Value.opacity + }); + } } public void apply_flags(GridColumnSettingsFeatureFlags flags) { @@ -84,6 +101,9 @@ namespace mbts.spark { // font weight can_override_font_weight = (flags & GridColumnSettingsFeatureFlags.ImmutableFontWeight) == 0; is_font_weight_overridden &= can_override_font_weight; + // background color + can_override_background_color = (flags & GridColumnSettingsFeatureFlags.ImmutableBackgroundColor) == 0; + is_background_color_overridden &= can_override_background_color; } public override string ToString() => $"{display_name} ({id})"; From 7aaae817ac3b66f6bf27bfd0cbe4525c753c6684 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Mon, 12 Aug 2019 13:02:48 -0500 Subject: [PATCH 06/44] higher level changes as a result of previous checkin --- .../Modules/Market/MarketView/MarketViewVM.cs | 15 ++++++++------- .../Market/MarketView/MarketViewWindowFactory.cs | 5 +++-- .../FrameworkElementColumns/HyperlinkColumn.cs | 5 +++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs index 73581518c..6b79b98fd 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs @@ -1,5 +1,6 @@ using bts.api; using bts.collections; +using bts.proto; using bts.utils; using mbts.persist; using mbts.spark.filters; @@ -46,8 +47,8 @@ namespace mbts.spark { add_col(Columns.BidImpliedSize, implied_size_col_header, r => r.bid_implied_size.ToString(), nameof(Row.bid_implied_size), DefaultColumnWidths.ImpliedDirectMergedSize, bid_implied_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right); add_col(Columns.BidDirectSize, direct_size_col_header, r => r.bid_direct_size.ToString(), nameof(Row.bid_direct_size), DefaultColumnWidths.ImpliedDirectMergedSize, bid_direct_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right); add_hl_merged_size_col(Columns.BidMergedSize, merged_size_col_header, nameof(Row.bid_merged_size), nameof(Row.bid_merged_size_text), nameof(Row.bid_merged_size_click), bid_merged_size_filter, BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right); - add_hl_price_col(Columns.Bid, "Bid", nameof(Row.bid_price), nameof(Row.bid_price_click), bid_price_filter, BTSColors.header_text, BTSColors.MarketData.bid_brush, h_alignment: System.Windows.HorizontalAlignment.Right); - add_hl_price_col(Columns.Ask, "Ask", nameof(Row.ask_price), nameof(Row.ask_price_click), ask_price_filter, BTSColors.header_text, BTSColors.MarketData.ask_brush, h_alignment: System.Windows.HorizontalAlignment.Right); + add_hl_price_col(Columns.Bid, "Bid", nameof(Row.bid_price), nameof(Row.bid_price_click), bid_price_filter, BTSColors.header_text, new ColorOpacityProto(BTSColors.MarketData.bid.ToUint()), h_alignment: System.Windows.HorizontalAlignment.Right); + add_hl_price_col(Columns.Ask, "Ask", nameof(Row.ask_price), nameof(Row.ask_price_click), ask_price_filter, BTSColors.header_text, new ColorOpacityProto(BTSColors.MarketData.ask.ToUint()), h_alignment: System.Windows.HorizontalAlignment.Right); add_hl_merged_size_col(Columns.AskMergedSize, merged_size_col_header, nameof(Row.ask_merged_size), nameof(Row.ask_merged_size_text), nameof(Row.ask_merged_size_click), ask_merged_size_filter, BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right); add_col(Columns.AskDirectSize, direct_size_col_header, r => r.ask_direct_size.ToString(), nameof(Row.ask_direct_size), DefaultColumnWidths.ImpliedDirectMergedSize, ask_direct_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right); add_col(Columns.AskImpliedSize, implied_size_col_header, r => r.ask_implied_size.ToString(), nameof(Row.ask_implied_size), DefaultColumnWidths.ImpliedDirectMergedSize, ask_implied_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right); @@ -77,7 +78,7 @@ namespace mbts.spark { horizontal_alignment = h_alignment }); - void add_hl_price_col(Columns col_key, string header, string prop, string command_prop, IDataGridColumnFilter filter, Color foreground, Brush background, System.Windows.HorizontalAlignment h_alignment) => + void add_hl_price_col(Columns col_key, string header, string prop, string command_prop, IDataGridColumnFilter filter, Color foreground, ColorOpacityProto? background, System.Windows.HorizontalAlignment h_alignment) => add_hl_col(col_key, header, price_binding(prop), prop, command_prop, filter, DataGridFilterKnownTemplates.DoubleMinMax, DefaultColumnWidths.MViewPrice, foreground, background, DefaultSelectionHighlight, h_alignment); void add_hl_merged_size_col(Columns col_key, string header, string sort_prop, string text_prop, string command_prop, IDataGridColumnFilter filter, Color foreground, System.Windows.HorizontalAlignment h_alignment) => @@ -88,7 +89,7 @@ namespace mbts.spark { void add_hl_col( Columns col_key, string header, BindingBase binding, string prop, string command_prop, - IDataGridColumnFilter filter, string filter_template, double width, Color foreground, Brush background, Brush background_overlay, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) => + IDataGridColumnFilter filter, string filter_template, double width, Color foreground, ColorOpacityProto? background, Brush background_overlay, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) => columns.Add(new HyperlinkElementColumn( col_key, binding, new Binding(command_prop), filter, filter_template) { // it's necessary to have this id populated for grid settings @@ -96,7 +97,7 @@ namespace mbts.spark { Header = header, sort_member_path = prop, font_color_override = foreground, - background = background, + background_color_override = background, background_overlay = background_overlay, Width = DefaultColumnWidths.Price, horizontal_alignment = h_alignment @@ -111,8 +112,8 @@ namespace mbts.spark { // // make font-color immutable for Side, Size, (the font-color rule is hard-coded: MarketData.bid for Buy orders, MarketData.ask for Sells) var col_settings_flags = new Dictionary { - { Columns.Bid.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }, - { Columns.Ask.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }, + { Columns.Bid.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor | GridColumnSettingsFeatureFlags.ImmutableBackgroundColor }, + { Columns.Ask.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor | GridColumnSettingsFeatureFlags.ImmutableBackgroundColor}, { Columns.BidImpliedSize.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }, { Columns.BidDirectSize.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }, { Columns.BidMergedSize.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }, diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs index 38931a3eb..a400f4cb8 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs @@ -1,4 +1,5 @@ using bts.api; +using bts.proto; using mbts.persist; using mbts.spark; using mbts.spark.filters; @@ -86,8 +87,8 @@ namespace bts.shell { public static GridColumnSettings bid_implied_size => new GridColumnSettings(col_id(Columns.BidImpliedSize), DefaultColumnHeaders.ImpliedSize, font_color_override: BTSColors.MarketData.bid, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings bid_direct_size => new GridColumnSettings(col_id(Columns.BidDirectSize), DefaultColumnHeaders.DirectSize, font_color_override: BTSColors.MarketData.bid, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings bid_merged_size => new GridColumnSettings(col_id(Columns.BidMergedSize), DefaultColumnHeaders.MergedSize, font_color_override: BTSColors.MarketData.bid, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right); - public static GridColumnSettings bid => new GridColumnSettings(col_id(Columns.Bid), DefaultColumnHeaders.Bid, font_color_override: BTSColors.header_text, width:DefaultColumnWidths.MViewPrice, horizontal_alignment: System.Windows.HorizontalAlignment.Right); - public static GridColumnSettings ask => new GridColumnSettings(col_id(Columns.Ask), DefaultColumnHeaders.Ask, font_color_override: BTSColors.header_text, width: DefaultColumnWidths.MViewPrice, horizontal_alignment: System.Windows.HorizontalAlignment.Right); + public static GridColumnSettings bid => new GridColumnSettings(col_id(Columns.Bid), DefaultColumnHeaders.Bid, font_color_override: BTSColors.header_text, width:DefaultColumnWidths.MViewPrice, horizontal_alignment: System.Windows.HorizontalAlignment.Right, background_color_override: new ColorOpacityProto(BTSColors.MarketData.bid.ToUint())); + public static GridColumnSettings ask => new GridColumnSettings(col_id(Columns.Ask), DefaultColumnHeaders.Ask, font_color_override: BTSColors.header_text, width: DefaultColumnWidths.MViewPrice, horizontal_alignment: System.Windows.HorizontalAlignment.Right, background_color_override: new ColorOpacityProto(BTSColors.MarketData.ask.ToUint())); public static GridColumnSettings ask_merged_size => new GridColumnSettings(col_id(Columns.AskMergedSize), DefaultColumnHeaders.MergedSize, font_color_override: BTSColors.MarketData.ask, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings ask_direct_size => new GridColumnSettings(col_id(Columns.AskDirectSize), DefaultColumnHeaders.DirectSize, font_color_override: BTSColors.MarketData.ask, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings ask_implied_size => new GridColumnSettings(col_id(Columns.AskImpliedSize), DefaultColumnHeaders.ImpliedSize, font_color_override: BTSColors.MarketData.ask, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right); diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs b/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs index 258740e29..11750f370 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs @@ -22,20 +22,21 @@ namespace mbts.ui.controls { public IDataGridColumnFilter filter { get; } public string filter_template { get; } public Thickness padding { get; set; } = _default_padding; - public Brush background { get; set; } + public Brush background_overlay { get; set; } = DefaultSelectionHighlight; public void on_selection_fill(Brush selection_fill) => background_overlay = selection_fill; public override FrameworkElement view_factory() { - var hl = new HyperlinkCell { Foreground = font_brush, Background = background, Padding = padding }; + var hl = new HyperlinkCell { Foreground = font_brush, Padding = padding }; hl.SetBinding(HyperlinkCell.TextProperty, _binding); hl.SetBinding(HyperlinkCell.FontFamilyProperty, new Binding(nameof(font_family)) { Source = this }); hl.SetBinding(HyperlinkCell.FontSizeProperty, new Binding(nameof(font_size)) { Source = this }); hl.SetBinding(HyperlinkCell.HorizontalAlignmentProperty, new Binding(nameof(horizontal_alignment)) { Source = this }); hl.SetBinding(HyperlinkCell.CommandProperty, _command_binding); hl.SetBinding(HyperlinkCell.WidthProperty, new Binding(nameof(ActualWidth)) { Source = this }); + hl.SetBinding(HyperlinkCell.BackgroundProperty, new Binding(nameof(background_brush)) { Source = this }); if (background_overlay != null) { hl.SetBinding(BackgroundOverlayProperty, new Binding(nameof(ListBoxItem.IsSelected)) { Converter = new AnonymousValueConverter(val => val ? background_overlay : null), From 540559de3e73e0abc516740478f1ca4bf2713c26 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Mon, 12 Aug 2019 16:38:15 -0500 Subject: [PATCH 07/44] Adding sanitization routine for MarketViewWindowFactory --- .../MarketView/MarketViewWindowFactory.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs index a400f4cb8..6c846e15c 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs @@ -39,7 +39,7 @@ namespace bts.shell { IShellWindow _create(StartupData state) { var settings_manager = new WindowSettingsManager(_settings_hub, state.grid, - get: us => us.market_view_grid, + get: us => StartupData.sanitize(us.market_view_grid), set: (us, gs) => us.with(provided_market_view_gridsettings: gs)); return new MarketViewWindow(this, _bus, _orders_model, state, settings_manager); } @@ -69,6 +69,26 @@ namespace bts.shell { _sorting_criteria = sort; } + public static GridSettings sanitize(GridSettings s) { + if (s == null) { + return null; + } + + var columns = s.columns.ToList(); + var bid_col_index = columns.FindIndex(x => x.id == col_id(Columns.Bid)); + var ask_col_index = columns.FindIndex(x => x.id == col_id(Columns.Ask)); + if (bid_col_index > -1 && ask_col_index > -1) { + if (!columns[bid_col_index].background_color_override.HasValue) { + columns[bid_col_index] = columns[bid_col_index].with(background_color_override: new NullableColorOpacityProto(new ColorOpacityProto(BTSColors.MarketData.bid.ToUint()))); + } + if (!columns[ask_col_index].background_color_override.HasValue) { + columns[ask_col_index] = columns[ask_col_index].with(background_color_override: new NullableColorOpacityProto(new ColorOpacityProto(BTSColors.MarketData.ask.ToUint()))); + } + } + return s.with(columns); + } + + public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criterion); public IReadOnlyList sorting_criterion => _sorting_criteria ?? (_sorting_criteria = DefaultColumns.default_sorting_criterion.ToList()); From decdae424d65af7cefd30c52129d6e7ae8b10c04 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 09:22:02 -0500 Subject: [PATCH 08/44] new Adorner to convey row selection --- .../Controls/Adorners/RowSelectionAdorner.cs | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs diff --git a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs new file mode 100644 index 000000000..aa9daf6df --- /dev/null +++ b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using bts.utils; +using mbts.ui.extensions; + +namespace mbts.ui.controls.adorners { + public class RowSelectionAdorner : Adorner, DIYGrid.ISelectionHighlightListener { + Brush _fill = DIYGrid.DefaultSelectionHighlight; + Pen _stroke = DIYGrid.DefaultSelectionStroke; + + DIYGridRowsPresenter _diy_rp; + ScrollViewer _diy_scroll; + ScrollContentPresenter _diy_scp; + + #region Fill + public static readonly DependencyProperty FillProperty = + WPFHelper.create_dp( + nameof(Fill), + FrameworkPropertyMetadataOptions.AffectsRender, + (o, v) => o._fill = v, + DIYGrid.DefaultSelectionHighlight); + + public SolidColorBrush Fill { + get => GetValue(FillProperty) as SolidColorBrush; + set => SetValue(FillProperty, value); + } + #endregion + #region Stroke + public static readonly DependencyProperty StrokeProperty = + WPFHelper.create_dp( + nameof(Stroke), + FrameworkPropertyMetadataOptions.AffectsRender, + (o, v) => o._stroke = v, + DIYGrid.DefaultSelectionStroke); + + public Pen Stroke { + get => GetValue(StrokeProperty) as Pen; + set => SetValue(StrokeProperty, value); + } + #endregion + + public RowSelectionAdorner(FrameworkElement adorned_element, ScrollViewer scroll_viewer) : base(adorned_element) { + // we want our clicks to go through to the underlying grid + IsHitTestVisible = false; + + _diy_rp = (DIYGridRowsPresenter)adorned_element; + _diy_scroll = scroll_viewer; + _diy_scp = _diy_rp.descendants_of_type().empty_if_null().FirstOrDefault(); + + // so that we clear out any previously selected highlighted rows + _diy_rp.SubscribePreviewMouseDown((s, e) => InvalidateVisual()); + // the main event + _diy_rp.SubscribePreviewMouseUp((s, e) => InvalidateVisual()); + // so that we update the highlight as the grid scrolls + _diy_scroll.SubscribeScrollChanged((s, e) => InvalidateVisual()); + } + + + protected override void OnRender(DrawingContext drawingContext) { + base.OnRender(drawingContext); + if (AdornedElement is ListBox lb && lb.SelectedItems != null && lb.SelectedItems.Count > 0) { + foreach(var lbi in lb.SelectedItems) { + if (_diy_rp.ItemContainerGenerator.ContainerFromItem(lbi) is FrameworkElement row && row.IsVisible) { + var top_left = lb.GetChildTopLeft(row); + var top_is_within_bounds = top_left.Y >= 0; + + // Note that the top of the row can still technically be visible but we wont show + // the adorner rectangle b/c the bottom of the row will be obscured by the scrollbar + var bottom_is_within_bounds = lb.GetChildBounds(row).BottomRight.Y <= _diy_scroll.ActualHeight; + if (top_is_within_bounds && bottom_is_within_bounds) { + drawingContext.DrawRectangle(_fill, + _stroke, + new Rect(top_left, new Point(top_left.X + row.ActualWidth, top_left.Y + row.ActualHeight))); + } + } + } + } + } + + public void on_selection_fill(Brush selection_fill) { + var selection_brush = (SolidColorBrush)selection_fill; + Fill = selection_brush; + Stroke = new Pen(selection_brush.Color.to_solid_brush(), 1); + InvalidateVisual(); + } + } +} \ No newline at end of file From 5ac8a46a6c19969f0a7de5d36f0a5db4d6481ef5 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 09:22:49 -0500 Subject: [PATCH 09/44] DIYGrid makes use of new RowSelectionAdorner --- src/client/spark/view/Controls/DIYGrid/DIYGrid.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs index 7b32426c3..cfdf18b0d 100644 --- a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs +++ b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs @@ -126,6 +126,7 @@ namespace mbts.ui.controls { double _row_height = DIYGrid.DefaultRowHeight; DIYGrid _grid; DragRectAdorner _drag_rect_adorner; + RowSelectionAdorner _rsa; ScrollViewer _scroll_viewer; Point? _drag_start; double _drag_start_vertical_drift; @@ -148,12 +149,17 @@ namespace mbts.ui.controls { _drag_rect_adorner.SetResourceReference(DragRectAdorner.StrokeProperty, DIYGrid.SelectionStrokeKey); _drag_rect_adorner.attach(); } + _rsa = new RowSelectionAdorner(this, _scroll_viewer); + _rsa.attach(); }; Unloaded += (s, e) => { if (_drag_rect_adorner != null) { _drag_rect_adorner.detach(); Disposable.dispose(ref _drag_rect_adorner); } + if (_rsa != null) { + _rsa.detach(); + } }; void on_row_height_changed(double v) => _row_height = v; } @@ -263,6 +269,12 @@ namespace mbts.ui.controls { o.Resources[SelectionStrokeKey] = new Pen(o.SelectionHighlight.Color.to_solid_brush().frozen(), 1).frozen(); foreach (var col in o.Columns.empty_if_null().OfType()) col.on_selection_fill(v); + var ad_layer = System.Windows.Documents.AdornerLayer.GetAdornerLayer(o); + if (ad_layer != null) { + foreach (var ad in ad_layer.descendants_of_type()) { + ad.on_selection_fill(v); + } + } }, (o, v) => v as SolidColorBrush ?? DefaultSelectionHighlight, DefaultSelectionHighlight); From 910cf204734acec77cbf5e35f61f1b635e2bbe18 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 10:05:46 -0500 Subject: [PATCH 10/44] sanitize existing persisted grid state --- .../Modules/Market/MarketView/MarketViewWindowFactory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs index 6c846e15c..4e5edbf55 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs @@ -37,8 +37,8 @@ namespace bts.shell { _bus.post(SparkTags.ShowWindow, _create(StartupData.Default(criteria))); IShellWindow _create(StartupData state) { - var settings_manager = new WindowSettingsManager(_settings_hub, - state.grid, + var settings_manager = new WindowSettingsManager(_settings_hub, + StartupData.sanitize(state.grid), get: us => StartupData.sanitize(us.market_view_grid), set: (us, gs) => us.with(provided_market_view_gridsettings: gs)); return new MarketViewWindow(this, _bus, _orders_model, state, settings_manager); From b292f50d99a9a86329b8bc8172c7b5e34cf40b2d Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 10:16:48 -0500 Subject: [PATCH 11/44] Removing Background selection/active highlighting from DIYGridRowStyle --- .../view/Controls/DIYGrid/DIYGridResources.xaml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/DIYGridResources.xaml b/src/client/spark/view/Controls/DIYGrid/DIYGridResources.xaml index d066fbb96..45a875517 100644 --- a/src/client/spark/view/Controls/DIYGrid/DIYGridResources.xaml +++ b/src/client/spark/view/Controls/DIYGrid/DIYGridResources.xaml @@ -29,22 +29,6 @@ VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> - - - - - - - - - - - - - - - - From dd9ca350af64180550172632af40ffbb201ccc22 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 10:51:06 -0500 Subject: [PATCH 12/44] RowSelectionAdorner bounds check should use ScrollContentPresenter for X point --- .../spark/view/Controls/Adorners/RowSelectionAdorner.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs index aa9daf6df..d76d7c663 100644 --- a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs +++ b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs @@ -74,9 +74,12 @@ namespace mbts.ui.controls.adorners { // the adorner rectangle b/c the bottom of the row will be obscured by the scrollbar var bottom_is_within_bounds = lb.GetChildBounds(row).BottomRight.Y <= _diy_scroll.ActualHeight; if (top_is_within_bounds && bottom_is_within_bounds) { + // we use the scroll content presenter in the X point calculation instead of the row + // because of the OB which has a right side panel that takes up some space over + // row width drawingContext.DrawRectangle(_fill, _stroke, - new Rect(top_left, new Point(top_left.X + row.ActualWidth, top_left.Y + row.ActualHeight))); + new Rect(top_left, new Point(top_left.X + _diy_scp.ActualWidth, top_left.Y + row.ActualHeight))); } } } From 3046871cf409d662a4414756e5bda8b4b749c1fd Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 10:59:52 -0500 Subject: [PATCH 13/44] removing background_overlay property from HyperLinkColumn, et al --- .../Modules/Market/MarketView/MarketViewVM.cs | 9 ++++----- .../Controls/DIYGrid/CellRender/HyperlinkCell.cs | 5 ----- .../FrameworkElementColumns/HyperlinkColumn.cs | 14 +------------- src/client/spark/view/Controls/DIYGrid/DIYGrid.cs | 12 ------------ 4 files changed, 5 insertions(+), 35 deletions(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs index 6b79b98fd..e6673fc4e 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs @@ -79,17 +79,17 @@ namespace mbts.spark { }); void add_hl_price_col(Columns col_key, string header, string prop, string command_prop, IDataGridColumnFilter filter, Color foreground, ColorOpacityProto? background, System.Windows.HorizontalAlignment h_alignment) => - add_hl_col(col_key, header, price_binding(prop), prop, command_prop, filter, DataGridFilterKnownTemplates.DoubleMinMax, DefaultColumnWidths.MViewPrice, foreground, background, DefaultSelectionHighlight, h_alignment); + add_hl_col(col_key, header, price_binding(prop), prop, command_prop, filter, DataGridFilterKnownTemplates.DoubleMinMax, DefaultColumnWidths.MViewPrice, foreground, background, h_alignment); void add_hl_merged_size_col(Columns col_key, string header, string sort_prop, string text_prop, string command_prop, IDataGridColumnFilter filter, Color foreground, System.Windows.HorizontalAlignment h_alignment) => - add_hl_col(col_key, header, new Binding(text_prop), sort_prop, command_prop, filter, DataGridFilterKnownTemplates.UIntMinMax, DefaultColumnWidths.ImpliedDirectMergedSize, foreground, null, null, h_alignment); + add_hl_col(col_key, header, new Binding(text_prop), sort_prop, command_prop, filter, DataGridFilterKnownTemplates.UIntMinMax, DefaultColumnWidths.ImpliedDirectMergedSize, foreground, null, h_alignment); void add_hl_working_orders_col(Columns col_key, string header, string text_prop, string sort_prop, string command_prop, IDataGridColumnFilter filter, Color foreground, System.Windows.HorizontalAlignment h_alignment) => - add_hl_col(col_key, header, new Binding(text_prop), sort_prop, command_prop, filter, DataGridFilterKnownTemplates.IntMinMax, working_orders_col_width, foreground, null, null, h_alignment); + add_hl_col(col_key, header, new Binding(text_prop), sort_prop, command_prop, filter, DataGridFilterKnownTemplates.IntMinMax, working_orders_col_width, foreground, null, h_alignment); void add_hl_col( Columns col_key, string header, BindingBase binding, string prop, string command_prop, - IDataGridColumnFilter filter, string filter_template, double width, Color foreground, ColorOpacityProto? background, Brush background_overlay, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) => + IDataGridColumnFilter filter, string filter_template, double width, Color foreground, ColorOpacityProto? background, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) => columns.Add(new HyperlinkElementColumn( col_key, binding, new Binding(command_prop), filter, filter_template) { // it's necessary to have this id populated for grid settings @@ -98,7 +98,6 @@ namespace mbts.spark { sort_member_path = prop, font_color_override = foreground, background_color_override = background, - background_overlay = background_overlay, Width = DefaultColumnWidths.Price, horizontal_alignment = h_alignment }); diff --git a/src/client/spark/view/Controls/DIYGrid/CellRender/HyperlinkCell.cs b/src/client/spark/view/Controls/DIYGrid/CellRender/HyperlinkCell.cs index 8d9e326cb..e9e5ae634 100644 --- a/src/client/spark/view/Controls/DIYGrid/CellRender/HyperlinkCell.cs +++ b/src/client/spark/view/Controls/DIYGrid/CellRender/HyperlinkCell.cs @@ -304,11 +304,6 @@ namespace mbts.ui.controls { } drawingContext.Pop(); } - if (bg != null) { - var bgo = GetBackgroundOverlay(this); - if (bgo != null) - drawingContext.DrawRectangle(bgo, null, rect); - } } bool _point_horizontally_over_text(double x) { diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs b/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs index 11750f370..efeaa83b7 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs @@ -7,7 +7,7 @@ using System.Windows.Media; namespace mbts.ui.controls { partial class DIYGrid { - internal class HyperlinkElementColumn : FrameworkElementColumnBase, IFrameworkElementColumn, IFilterableColumn, IKeyedColumn, ISelectionHighlightListener { + internal class HyperlinkElementColumn : FrameworkElementColumnBase, IFrameworkElementColumn, IFilterableColumn, IKeyedColumn { static readonly Thickness _default_padding = new Thickness(6, 0, 6, 0); readonly BindingBase _binding, _command_binding; @@ -23,11 +23,6 @@ namespace mbts.ui.controls { public string filter_template { get; } public Thickness padding { get; set; } = _default_padding; - public Brush background_overlay { get; set; } = DefaultSelectionHighlight; - - public void on_selection_fill(Brush selection_fill) => - background_overlay = selection_fill; - public override FrameworkElement view_factory() { var hl = new HyperlinkCell { Foreground = font_brush, Padding = padding }; hl.SetBinding(HyperlinkCell.TextProperty, _binding); @@ -37,13 +32,6 @@ namespace mbts.ui.controls { hl.SetBinding(HyperlinkCell.CommandProperty, _command_binding); hl.SetBinding(HyperlinkCell.WidthProperty, new Binding(nameof(ActualWidth)) { Source = this }); hl.SetBinding(HyperlinkCell.BackgroundProperty, new Binding(nameof(background_brush)) { Source = this }); - if (background_overlay != null) { - hl.SetBinding(BackgroundOverlayProperty, new Binding(nameof(ListBoxItem.IsSelected)) { - Converter = new AnonymousValueConverter(val => val ? background_overlay : null), - Mode = BindingMode.OneWay, - RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(ListBoxItem), 1) - }); - } return hl; } } diff --git a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs index cfdf18b0d..b5687ebd0 100644 --- a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs +++ b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs @@ -608,18 +608,6 @@ namespace mbts.ui.controls { // Public Properties #region Public Properties - public static readonly DependencyProperty BackgroundOverlayProperty = - DependencyProperty.RegisterAttached( - "BackgroundOverlay", - typeof(Brush), - typeof(DIYGrid), - new FrameworkPropertyMetadata( - null, - FrameworkPropertyMetadataOptions.AffectsRender)); - - public static Brush GetBackgroundOverlay(DependencyObject d) => d.GetValue(BackgroundOverlayProperty) as Brush; - public static void SetBackgroundOverlay(DependencyObject d, Brush value) => d.SetValue(BackgroundOverlayProperty, value); - #region RowStyle public static readonly DependencyProperty RowStyleProperty = WPFHelper.create_dp( From 3c7dbc04892df463da118306b787c2599e06a257 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 11:17:50 -0500 Subject: [PATCH 14/44] RowSelectionAdorner now implements IDisposable --- .../view/Controls/Adorners/RowSelectionAdorner.cs | 13 +++++++++---- src/client/spark/view/Controls/DIYGrid/DIYGrid.cs | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs index d76d7c663..c7625c654 100644 --- a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs +++ b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs @@ -10,13 +10,14 @@ using bts.utils; using mbts.ui.extensions; namespace mbts.ui.controls.adorners { - public class RowSelectionAdorner : Adorner, DIYGrid.ISelectionHighlightListener { + public class RowSelectionAdorner : Adorner, DIYGrid.ISelectionHighlightListener, IDisposable { Brush _fill = DIYGrid.DefaultSelectionHighlight; Pen _stroke = DIYGrid.DefaultSelectionStroke; DIYGridRowsPresenter _diy_rp; ScrollViewer _diy_scroll; ScrollContentPresenter _diy_scp; + List _disposables = new List(); #region Fill public static readonly DependencyProperty FillProperty = @@ -54,11 +55,11 @@ namespace mbts.ui.controls.adorners { _diy_scp = _diy_rp.descendants_of_type().empty_if_null().FirstOrDefault(); // so that we clear out any previously selected highlighted rows - _diy_rp.SubscribePreviewMouseDown((s, e) => InvalidateVisual()); + _disposables.Add(_diy_rp.SubscribePreviewMouseDown((s, e) => InvalidateVisual())); // the main event - _diy_rp.SubscribePreviewMouseUp((s, e) => InvalidateVisual()); + _disposables.Add(_diy_rp.SubscribePreviewMouseUp((s, e) => InvalidateVisual())); // so that we update the highlight as the grid scrolls - _diy_scroll.SubscribeScrollChanged((s, e) => InvalidateVisual()); + _disposables.Add(_diy_scroll.SubscribeScrollChanged((s, e) => InvalidateVisual())); } @@ -92,5 +93,9 @@ namespace mbts.ui.controls.adorners { Stroke = new Pen(selection_brush.Color.to_solid_brush(), 1); InvalidateVisual(); } + + public void Dispose() { + _disposables.DisposeAll(); + } } } \ No newline at end of file diff --git a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs index b5687ebd0..c8267344d 100644 --- a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs +++ b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs @@ -159,6 +159,7 @@ namespace mbts.ui.controls { } if (_rsa != null) { _rsa.detach(); + Disposable.dispose(ref _rsa); } }; void on_row_height_changed(double v) => _row_height = v; From 231f596ad72dafede26096b8dd189a41a2d7b66b Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 14:17:33 -0500 Subject: [PATCH 15/44] switching to NullableColorProto in wrap up attempt --- .../Modules/Market/MarketView/MarketViewVM.cs | 8 ++++---- .../Market/MarketView/MarketViewWindowFactory.cs | 8 ++++---- .../view/Controls/DIYGrid/Columns/ColumnBase.cs | 14 +++++++------- src/client/spark/view/Controls/DIYGrid/DIYGrid.cs | 2 +- .../DIYGrid/Settings/GridColumnSettings.cs | 10 +++++----- .../DIYGrid/Settings/GridColumnSettingsVM.cs | 8 ++++---- .../view/Controls/DIYGrid/Settings/GridSettings.cs | 14 +++++++------- .../DIYGrid/Settings/GridSettingsManager.cs | 4 ++-- .../Controls/DIYGrid/Settings/GridSettingsVM.cs | 7 +++++-- .../Settings/ImmutableColumnSettingsStore.cs | 4 ++-- .../DIYGrid/Settings/SimpleGridColumnSettingsVM.cs | 7 +++---- .../DIYGrid/Settings/SimpleGridSettingsManager.cs | 4 ++-- .../DIYGrid/Settings/SimpleGridSettingsVM.cs | 7 +++++-- 13 files changed, 51 insertions(+), 46 deletions(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs index e6673fc4e..9e67a4bb1 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs @@ -47,8 +47,8 @@ namespace mbts.spark { add_col(Columns.BidImpliedSize, implied_size_col_header, r => r.bid_implied_size.ToString(), nameof(Row.bid_implied_size), DefaultColumnWidths.ImpliedDirectMergedSize, bid_implied_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right); add_col(Columns.BidDirectSize, direct_size_col_header, r => r.bid_direct_size.ToString(), nameof(Row.bid_direct_size), DefaultColumnWidths.ImpliedDirectMergedSize, bid_direct_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right); add_hl_merged_size_col(Columns.BidMergedSize, merged_size_col_header, nameof(Row.bid_merged_size), nameof(Row.bid_merged_size_text), nameof(Row.bid_merged_size_click), bid_merged_size_filter, BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right); - add_hl_price_col(Columns.Bid, "Bid", nameof(Row.bid_price), nameof(Row.bid_price_click), bid_price_filter, BTSColors.header_text, new ColorOpacityProto(BTSColors.MarketData.bid.ToUint()), h_alignment: System.Windows.HorizontalAlignment.Right); - add_hl_price_col(Columns.Ask, "Ask", nameof(Row.ask_price), nameof(Row.ask_price_click), ask_price_filter, BTSColors.header_text, new ColorOpacityProto(BTSColors.MarketData.ask.ToUint()), h_alignment: System.Windows.HorizontalAlignment.Right); + add_hl_price_col(Columns.Bid, "Bid", nameof(Row.bid_price), nameof(Row.bid_price_click), bid_price_filter, BTSColors.header_text, BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right); + add_hl_price_col(Columns.Ask, "Ask", nameof(Row.ask_price), nameof(Row.ask_price_click), ask_price_filter, BTSColors.header_text, BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right); add_hl_merged_size_col(Columns.AskMergedSize, merged_size_col_header, nameof(Row.ask_merged_size), nameof(Row.ask_merged_size_text), nameof(Row.ask_merged_size_click), ask_merged_size_filter, BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right); add_col(Columns.AskDirectSize, direct_size_col_header, r => r.ask_direct_size.ToString(), nameof(Row.ask_direct_size), DefaultColumnWidths.ImpliedDirectMergedSize, ask_direct_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right); add_col(Columns.AskImpliedSize, implied_size_col_header, r => r.ask_implied_size.ToString(), nameof(Row.ask_implied_size), DefaultColumnWidths.ImpliedDirectMergedSize, ask_implied_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right); @@ -78,7 +78,7 @@ namespace mbts.spark { horizontal_alignment = h_alignment }); - void add_hl_price_col(Columns col_key, string header, string prop, string command_prop, IDataGridColumnFilter filter, Color foreground, ColorOpacityProto? background, System.Windows.HorizontalAlignment h_alignment) => + void add_hl_price_col(Columns col_key, string header, string prop, string command_prop, IDataGridColumnFilter filter, Color foreground, Color? background, System.Windows.HorizontalAlignment h_alignment) => add_hl_col(col_key, header, price_binding(prop), prop, command_prop, filter, DataGridFilterKnownTemplates.DoubleMinMax, DefaultColumnWidths.MViewPrice, foreground, background, h_alignment); void add_hl_merged_size_col(Columns col_key, string header, string sort_prop, string text_prop, string command_prop, IDataGridColumnFilter filter, Color foreground, System.Windows.HorizontalAlignment h_alignment) => @@ -89,7 +89,7 @@ namespace mbts.spark { void add_hl_col( Columns col_key, string header, BindingBase binding, string prop, string command_prop, - IDataGridColumnFilter filter, string filter_template, double width, Color foreground, ColorOpacityProto? background, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) => + IDataGridColumnFilter filter, string filter_template, double width, Color foreground, Color? background, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) => columns.Add(new HyperlinkElementColumn( col_key, binding, new Binding(command_prop), filter, filter_template) { // it's necessary to have this id populated for grid settings diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs index 4e5edbf55..2d7b6e075 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs @@ -79,10 +79,10 @@ namespace bts.shell { var ask_col_index = columns.FindIndex(x => x.id == col_id(Columns.Ask)); if (bid_col_index > -1 && ask_col_index > -1) { if (!columns[bid_col_index].background_color_override.HasValue) { - columns[bid_col_index] = columns[bid_col_index].with(background_color_override: new NullableColorOpacityProto(new ColorOpacityProto(BTSColors.MarketData.bid.ToUint()))); + columns[bid_col_index] = columns[bid_col_index].with(background_color_override: new NullableColorProto(BTSColors.MarketData.bid.ToUint())); } if (!columns[ask_col_index].background_color_override.HasValue) { - columns[ask_col_index] = columns[ask_col_index].with(background_color_override: new NullableColorOpacityProto(new ColorOpacityProto(BTSColors.MarketData.ask.ToUint()))); + columns[ask_col_index] = columns[ask_col_index].with(background_color_override: new NullableColorProto(BTSColors.MarketData.ask.ToUint())); } } return s.with(columns); @@ -107,8 +107,8 @@ namespace bts.shell { public static GridColumnSettings bid_implied_size => new GridColumnSettings(col_id(Columns.BidImpliedSize), DefaultColumnHeaders.ImpliedSize, font_color_override: BTSColors.MarketData.bid, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings bid_direct_size => new GridColumnSettings(col_id(Columns.BidDirectSize), DefaultColumnHeaders.DirectSize, font_color_override: BTSColors.MarketData.bid, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings bid_merged_size => new GridColumnSettings(col_id(Columns.BidMergedSize), DefaultColumnHeaders.MergedSize, font_color_override: BTSColors.MarketData.bid, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right); - public static GridColumnSettings bid => new GridColumnSettings(col_id(Columns.Bid), DefaultColumnHeaders.Bid, font_color_override: BTSColors.header_text, width:DefaultColumnWidths.MViewPrice, horizontal_alignment: System.Windows.HorizontalAlignment.Right, background_color_override: new ColorOpacityProto(BTSColors.MarketData.bid.ToUint())); - public static GridColumnSettings ask => new GridColumnSettings(col_id(Columns.Ask), DefaultColumnHeaders.Ask, font_color_override: BTSColors.header_text, width: DefaultColumnWidths.MViewPrice, horizontal_alignment: System.Windows.HorizontalAlignment.Right, background_color_override: new ColorOpacityProto(BTSColors.MarketData.ask.ToUint())); + public static GridColumnSettings bid => new GridColumnSettings(col_id(Columns.Bid), DefaultColumnHeaders.Bid, font_color_override: BTSColors.header_text, width:DefaultColumnWidths.MViewPrice, horizontal_alignment: System.Windows.HorizontalAlignment.Right, background_color_override: BTSColors.MarketData.bid); + public static GridColumnSettings ask => new GridColumnSettings(col_id(Columns.Ask), DefaultColumnHeaders.Ask, font_color_override: BTSColors.header_text, width: DefaultColumnWidths.MViewPrice, horizontal_alignment: System.Windows.HorizontalAlignment.Right, background_color_override: BTSColors.MarketData.ask); public static GridColumnSettings ask_merged_size => new GridColumnSettings(col_id(Columns.AskMergedSize), DefaultColumnHeaders.MergedSize, font_color_override: BTSColors.MarketData.ask, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings ask_direct_size => new GridColumnSettings(col_id(Columns.AskDirectSize), DefaultColumnHeaders.DirectSize, font_color_override: BTSColors.MarketData.ask, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings ask_implied_size => new GridColumnSettings(col_id(Columns.AskImpliedSize), DefaultColumnHeaders.ImpliedSize, font_color_override: BTSColors.MarketData.ask, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right); diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs index 6bbaabe2c..062e17c68 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs @@ -174,19 +174,19 @@ namespace mbts.ui.controls { //readonly ExternalProperty _font_weigh FontWeight _fallback_font_weight; Color _fallback_font_color; - ColorOpacityProto _fallback_background_color; + Color? _fallback_background_color; double _fallback_font_size; FontFamily _fallback_font_family; FontWeight? _font_weight_override; Color? _font_color_override; - ColorOpacityProto? _background_color_override; + Color? _background_color_override; object _header_copy; protected ColumnBase() { var gs = GridSettings.Default; _fallback_font_weight = gs.font_weight; _fallback_font_color = gs.font_color.rgb_color(); - _fallback_background_color = gs.background_color; + _fallback_background_color = gs.background_color.value; _fallback_font_size = gs.font_size; _fallback_font_family = new FontFamily(gs.font_family); original_width = double.NaN; @@ -219,9 +219,9 @@ namespace mbts.ui.controls { public FontWeight font_weight => font_weight_override ?? _fallback_font_weight; public Color font_color => font_color_override ?? _fallback_font_color; public Brush font_brush => new SolidColorBrush(font_color); - public ColorOpacityProto? background_color_override { get => _background_color_override; set => _set_font_param(ref _background_color_override, value); } - public ColorOpacityProto background_color => background_color_override ?? _fallback_background_color; - public Brush background_brush => background_color.to_brush(); + public Color? background_color_override { get => _background_color_override; set => _set_font_param(ref _background_color_override, value); } + public Color? background_color => background_color_override ?? _fallback_background_color; + public Brush background_brush => background_color?.to_brush(); // TODO: find a better way to store the header-property in a thread-safe manner - a value for GridSettings.display_name, more specifically. // Since save_state is called from a different thread in IShared/SlowWindows, it is not safe to access the DependencyProperty store from that method. // By updating a local _header_copy field in the Header setter, the DependencyProperty lookup may be bypassed when appropriate (see create method below). @@ -263,7 +263,7 @@ namespace mbts.ui.controls { } // 'fallback' font-params (aka 'grid-level' font-params) - public void set_fallback_font_params(FontFamily font_family, double font_size, Color font_color, FontWeight font_weight, ColorOpacityProto background_color) { + public void set_fallback_font_params(FontFamily font_family, double font_size, Color font_color, FontWeight font_weight, Color? background_color) { using (ReflectionHelper.detect_property_changes(this, _raise_prop_changed, nameof(font_family), nameof(font_size), nameof(font_color), nameof(font_weight), nameof(background_color), nameof(background_brush))) { _fallback_font_family = font_family; _fallback_font_size = font_size; diff --git a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs index c8267344d..bfab02f71 100644 --- a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs +++ b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs @@ -255,7 +255,7 @@ namespace mbts.ui.controls { // (e.g MarketView bid/ask columns, bc their background is not transparent, it covers the ListBoxItem selection-highlight). public static readonly SolidColorBrush DefaultSelectionHighlight = new SolidColorBrush(Colors.MediumSlateBlue) { Opacity = 0.4 }; // I have no idea why DefaultBackgroundColor needs to be frozen but DefaultSelectionHighlight is apparently fine as is - public static readonly SolidColorBrush DefaultBackgroundColor = new SolidColorBrush(BTSColors.Grid.input_cell_background) { Opacity = 0.40 }.frozen(); + public static readonly SolidColorBrush DefaultBackgroundColor = null; //new SolidColorBrush(BTSColors.Grid.input_cell_background) { Opacity = 0.40 }.frozen(); public static readonly Pen DefaultSelectionStroke = new Pen(Brushes.MediumSlateBlue, 1); readonly NotifyCollectionChangedEventHandler _sort_descriptions_collection_changed_cb; double _inactive_selection_opacity = 0.2; diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs index 73650567a..770e7e52c 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs @@ -61,7 +61,7 @@ namespace mbts.ui.settings { readonly double _horizontal_offset; [ProtoMember(10)] - readonly NullableColorOpacityProto _background_color_override; + readonly NullableColorProto _background_color_override; public GridColumnSettings() { _is_visible = _default_is_visible; @@ -72,7 +72,7 @@ namespace mbts.ui.settings { } public GridColumnSettings(string id, string display_name = null, bool is_visible = _default_is_visible, bool is_collapsed = _default_is_collapsed, FontWeight? font_weight_override = null, Color? font_color_override = null, - double width = _default_width, HorizontalAlignment horizontal_alignment = _default_horizontal_alignment, double horizontal_offset = _default_horizontal_offset, ColorOpacityProto? background_color_override = null) { + double width = _default_width, HorizontalAlignment horizontal_alignment = _default_horizontal_alignment, double horizontal_offset = _default_horizontal_offset, Color? background_color_override = null) { _id = id; _display_name = display_name; _is_visible = is_visible; @@ -82,7 +82,7 @@ namespace mbts.ui.settings { _width = width; _horizontal_alignment = horizontal_alignment; _horizontal_offset = horizontal_offset; - _background_color_override = new NullableColorOpacityProto(background_color_override); + _background_color_override = new NullableColorProto(background_color_override); } public string id => _id; @@ -94,11 +94,11 @@ namespace mbts.ui.settings { public HorizontalAlignment horizontal_alignment => _horizontal_alignment; public double horizontal_offset => _horizontal_offset; public string display_name => _display_name; - public ColorOpacityProto? background_color_override => _background_color_override.value; + public Color? background_color_override => _background_color_override.value; public GridColumnSettings with( string display_name = null, bool? is_visible = null, bool? is_collapsed = null, NullableFontWeightProto? font_weight_override = null, NullableColorProto? font_color_override = null, - double? width = null, HorizontalAlignment? horizontal_alignment = null, double? horizontal_offset = null, NullableColorOpacityProto? background_color_override = null) => + double? width = null, HorizontalAlignment? horizontal_alignment = null, double? horizontal_offset = null, NullableColorProto? background_color_override = null) => // new GridColumnSettings(_id, display_name ?? this.display_name, diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs index 521924964..dcb799b83 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs @@ -98,8 +98,7 @@ namespace mbts.spark { width, horizontal_alignment, background_color_override: is_background_color_overridden ? - new NullableColorOpacityProto(new ColorOpacityProto(background_color_override.color, background_color_override.opacity)) - : default); + new NullableColorProto(background_color_override.color) : default); var animations_lookup = predicate_animations.ToFlatLookup(pa => pa.predicate.create_assigned(owner._predicate_data_factory), pa => pa.animations.Select(a => a.create())); return (settings, animations_lookup); } @@ -125,8 +124,9 @@ namespace mbts.spark { is_background_color_overridden = _settings.background_color_override.HasValue; if (is_background_color_overridden) { background_color_override.load_from( - new SolidColorBrush(_settings.background_color_override.Value.color) { - Opacity = _settings.background_color_override.Value.opacity }); + new SolidColorBrush(_settings.background_color_override.Value) { + //Opacity = _settings.background_color_override.Value.opacity + }); } predicate_animations.SetItems(value.animations.empty_if_null().Select(g => { var vm = new PredicateCellAnimationVM(id, owner._create_column_predicate_vm(id), owner._predicate_data_factory); diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs index ac0ddef91..9e63e69d7 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs @@ -21,7 +21,7 @@ namespace mbts.ui.settings { public static GridSettings Default => new GridSettings( selection_highlight: new ColorOpacityProto(FallbackValues.selection_highlight.Color, FallbackValues.selection_highlight.Opacity), - background_color: new ColorOpacityProto(FallbackValues.background_color.Color, FallbackValues.background_color.Opacity)); + background_color: null);//new ColorOpacityProto(FallbackValues.background_color.Color, FallbackValues.background_color.Opacity)); // corrects any inappropriate values that would render the grid unusable (usually nulls) // NOTE: if you add a property to GridSettings that could have such a value, please add a conditional-correction for it below) @@ -69,7 +69,7 @@ namespace mbts.ui.settings { [ProtoMember(7)] List _sorting_criterion; [ProtoMember(8)] - readonly ColorOpacityProto _background_color; + readonly NullableColorProto _background_color; public GridSettings() { _font_family = _default_font_family; @@ -78,12 +78,12 @@ namespace mbts.ui.settings { _font_color = _default_font_color; // new setting in proto defaulted here - _background_color = new ColorOpacityProto(DIYGrid.DefaultBackgroundColor.Color, DIYGrid.DefaultBackgroundColor.Opacity); + _background_color = new NullableColorProto(); //new ColorOpacityProto(DIYGrid.DefaultBackgroundColor.Color, DIYGrid.DefaultBackgroundColor.Opacity); } public GridSettings( string font_family = _default_font_family, double font_size = _default_font_size, FontWeight font_weight = default, uint font_color = _default_font_color, - ColorOpacityProto? selection_highlight = null, IEnumerable columns = null, IEnumerable sorting_criterion = null, ColorOpacityProto? background_color = null) { + ColorOpacityProto? selection_highlight = null, IEnumerable columns = null, IEnumerable sorting_criterion = null, NullableColorProto? background_color = null) { // _font_family = font_family; _font_size = font_size; @@ -92,7 +92,7 @@ namespace mbts.ui.settings { _selection_highlight = selection_highlight ?? new ColorOpacityProto(0, 1); _columns = new List(columns.empty_if_null()); _sorting_criterion = new List(sorting_criterion.empty_if_null()); - _background_color = background_color ?? new ColorOpacityProto(DIYGrid.DefaultBackgroundColor.Color, DIYGrid.DefaultBackgroundColor.Opacity); + _background_color = background_color ?? new NullableColorProto(); } public string font_family => _font_family; @@ -100,14 +100,14 @@ namespace mbts.ui.settings { public uint font_color => _font_color; public FontWeight font_weight => FontWeight.FromOpenTypeWeight(_font_weight); public ColorOpacityProto selection_highlight => _selection_highlight; - public ColorOpacityProto background_color => _background_color; + public NullableColorProto background_color => _background_color; public IReadOnlyList columns => _columns ?? (_columns = new List(0)); [Obsolete] // TODO: remove sorting_criterion from GridSettings entirely. This should be part of IShellWindow's StartupData, since it is an instance-specific setting, and prob not part of the shared defaults public IReadOnlyList sorting_criterion => _sorting_criterion ?? (_sorting_criterion = new List(0)); public static GridSettings get_default() => new GridSettings(_default_font_family, _default_font_size, FontWeights.Normal, _default_font_color, new ColorOpacityProto(DIYGrid.DefaultSelectionHighlight.Color, DIYGrid.DefaultSelectionHighlight.Opacity), - background_color: new ColorOpacityProto(DIYGrid.DefaultBackgroundColor.Color, DIYGrid.DefaultBackgroundColor.Opacity)); + background_color: new NullableColorProto()); public GridSettings with(IEnumerable columns = null, IEnumerable sorting_criterion = null, string font_family = null, double font_size = double.NaN) => new GridSettings( diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs index eed7af4cd..8cf976235 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs @@ -77,7 +77,7 @@ namespace mbts.ui { _font_size = backing(nameof(font_size), () => grid_settings.font_size, nameof(font_size)); _font_color = backing(nameof(font_color), () => grid_settings.font_color.rgb_solid_brush().frozen(), nameof(grid_settings)); _selection_highlight = backing(nameof(selection_highlight), () => grid_settings.selection_highlight.to_brush().frozen(), nameof(grid_settings)); - _background_color = backing(nameof(background_color), () => grid_settings.background_color.to_brush().frozen(), nameof(grid_settings)); + _background_color = backing(nameof(background_color), () => grid_settings.background_color.value?.rgb_color().rgb_solid_brush().frozen(), nameof(grid_settings)); } public void Dispose() => @@ -114,7 +114,7 @@ namespace mbts.ui { var grid = value.general ?? GridSettings.Default; _grid_settings.set(grid); foreach (ColumnBase col in _columns) - col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color); + col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.value); _predicate_animations_data = value.predicate_animations; _animation_defs.clear(); foreach (var pa in _predicate_animations_data) { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs index 8caeebfff..539c17e36 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs @@ -1,5 +1,6 @@ using bts.api; using bts.collections; +using bts.proto; using bts.shell; using bts.utils; using mbts.collections; @@ -131,7 +132,7 @@ namespace mbts.spark { foreach (IGrouping g in animations) animation_map.AddOrUpdate(g.Key, p => animation_tuple(c: g), (p, t) => t.cell_animations.AddRange(g)); } - return _create_settings_obj(new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), col_settings, background_color: background_color.to_proto()), + return _create_settings_obj(new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), col_settings, background_color: new NullableColorProto(background_color.color.rgb_color())), animation_map.Select(kv => PredicateAnimations.create_data(kv.Key, kv.Value.cell_animations, kv.Value.row_animations, kv.Value.sounds))); // (List row_animations, List sounds, List cell_animations) animation_tuple(IEnumerable r = null, IEnumerable s = null, IGrouping c = null) => @@ -143,7 +144,9 @@ namespace mbts.spark { _font_weight.set(sd.general.font_weight); font_color.load_from(sd.general.font_color.rgb_solid_brush()); selection_highlight.load_from(sd.general.selection_highlight.to_brush()); - background_color.load_from(sd.general.background_color.to_brush()); + if (sd.general.background_color.value.HasValue) { + background_color.load_from(sd.general.background_color.value.Value.to_solid_brush()); + } _font_size.set(sd.general.font_size); var col_animations = new Dictionary>>(); predicate_animations.Clear(); diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/ImmutableColumnSettingsStore.cs b/src/client/spark/view/Controls/DIYGrid/Settings/ImmutableColumnSettingsStore.cs index 01503387f..5b6926814 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/ImmutableColumnSettingsStore.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/ImmutableColumnSettingsStore.cs @@ -70,7 +70,7 @@ namespace mbts.ui { } class ImmutableBackgroundColorOverrideStore : ImmutableColumnSettingStore { - NullableColorOpacityProto _value; + NullableColorProto _value; public ImmutableBackgroundColorOverrideStore() : base(GridColumnSettingsFeatureFlags.ImmutableBackgroundColor) { } @@ -79,7 +79,7 @@ namespace mbts.ui { settings.with(background_color_override: _value); public override void store(GridColumnSettings settings) => - _value = new NullableColorOpacityProto(settings.background_color_override); + _value = new NullableColorProto(settings.background_color_override); } class CompositeImmutableSettingsStore : ImmutableColumnSettingStore { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs index d4dc86c50..51f0f532e 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs @@ -60,8 +60,7 @@ namespace mbts.spark { width, horizontal_alignment, background_color_override: is_background_color_overridden ? - new NullableColorOpacityProto(new ColorOpacityProto(background_color_override.color, background_color_override.opacity)) - : default); + new NullableColorProto(background_color_override.color) : default); public void load_from(GridColumnSettings value) { _settings = value; @@ -84,8 +83,8 @@ namespace mbts.spark { is_background_color_overridden = _settings.background_color_override.HasValue; if (is_background_color_overridden) { background_color_override.load_from( - new SolidColorBrush(_settings.background_color_override.Value.color) { - Opacity = _settings.background_color_override.Value.opacity + new SolidColorBrush(_settings.background_color_override.Value) { + //Opacity = _settings.background_color_override.Value.opacity }); } } diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs index 4b66e19f6..0a002ac62 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs @@ -35,7 +35,7 @@ namespace mbts.ui { _font_size = backing(nameof(font_size), () => grid_settings.font_size, nameof(font_size)); _font_color = backing(nameof(font_color), () => grid_settings.font_color.rgb_solid_brush().frozen(), nameof(grid_settings)); _selection_highlight = backing(nameof(selection_highlight), () => grid_settings.selection_highlight.to_brush().frozen(), nameof(grid_settings)); - _background_color = backing(nameof(background_color), () => grid_settings.background_color.to_brush().frozen(), nameof(grid_settings)); + _background_color = backing(nameof(background_color), () => grid_settings.background_color.value?.rgb_color().rgb_solid_brush().frozen(), nameof(grid_settings)); _row_vms = row_vms; } @@ -88,7 +88,7 @@ namespace mbts.ui { grid = grid ?? GridSettings.Default; _grid_settings.set(grid); foreach (ColumnBase col in _columns) - col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color); + col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.value); // ** in the unfortunate event that we botch backwards compatability, and the columns don't bear a 1:1 relationship with the column-settings // don't add insult to injury by crashing ** if (grid_settings.columns != null) { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs index 220424bc6..5c01ac440 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs @@ -1,4 +1,5 @@ using bts.collections; +using bts.proto; using bts.utils; using mbts.ui; using mbts.ui.controls; @@ -105,7 +106,7 @@ namespace mbts.spark { } public GridSettings create() => - new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), columns.Select(c => c.create()), background_color: background_color.to_proto()); + new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), columns.Select(c => c.create()), background_color: new NullableColorProto(background_color.color.rgb_color())); public void load_from(GridSettings value) { if (value == null) @@ -115,7 +116,9 @@ namespace mbts.spark { _font_weight.set(value.font_weight); font_color.load_from(value.font_color.rgb_solid_brush()); selection_highlight.load_from(value.selection_highlight.to_brush()); - background_color.load_from(value.background_color.to_brush()); + if (value.background_color.value.HasValue) { + background_color.load_from(value.background_color.value.Value.to_solid_brush()); + } _font_size.set(value.font_size); var curr_col_id = current_column?.id; columns.SetItems(value.columns.Select(col => { From 9a76d9c857e2ebf80323ba8997fddedc6db15d52 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 14:21:58 -0500 Subject: [PATCH 16/44] argb-ness from John --- src/client/spark/core/data/Proto/NullableColorProto.cs | 10 ++-------- src/client/spark/view/Extensions/WPFExtensions.cs | 10 ++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/client/spark/core/data/Proto/NullableColorProto.cs b/src/client/spark/core/data/Proto/NullableColorProto.cs index 3fa15eba3..2fb827d08 100644 --- a/src/client/spark/core/data/Proto/NullableColorProto.cs +++ b/src/client/spark/core/data/Proto/NullableColorProto.cs @@ -16,14 +16,8 @@ namespace bts.proto { public NullableColorProto(uint value) => _value = value; - - public Color? value { - get { - if (_value.HasValue) - return _value.Value.rgb_color(); - return null; - } - } + public Color? value => _value?.rgb_color(); + public Color? argb => _value?.argb_color(); public bool Equals(NullableColorProto other) => EqualityComparer.nullable_equals(_value, other._value); diff --git a/src/client/spark/view/Extensions/WPFExtensions.cs b/src/client/spark/view/Extensions/WPFExtensions.cs index 643e20162..190eab50e 100644 --- a/src/client/spark/view/Extensions/WPFExtensions.cs +++ b/src/client/spark/view/Extensions/WPFExtensions.cs @@ -66,11 +66,18 @@ namespace mbts.ui { } } + // TODO: replace this method with 'argb_color' + // - before that, need to verify that no settings/colors become 'invisible' as a result. public static Color rgb_color(this UInt32 color) { var bytes = BitConverter.GetBytes(color); return Color.FromRgb(bytes[2], bytes[1], bytes[0]); } + public static Color argb_color(this uint color) { + var bytes = BitConverter.GetBytes(color); + return Color.FromArgb(bytes[3], bytes[2], bytes[1], bytes[0]); + } + public static SolidColorBrush to_brush(this BTSColor color) => new SolidColorBrush(color); @@ -103,6 +110,9 @@ namespace mbts.ui { return brush; } + public static Color with(this Color color, byte alpha) => + Color.FromArgb(alpha, color.R, color.G, color.B); + public static SolidColorBrush with(this SolidColorBrush brush, double opacity) { brush.Opacity = opacity; return brush; From ea2aee5044f8e2b3f7acba64a8df91128d48045a Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 15:04:40 -0500 Subject: [PATCH 17/44] utilzing new argb --- .../spark/view/Controls/DIYGrid/Columns/ColumnBase.cs | 2 +- .../view/Controls/DIYGrid/Settings/GridSettingsManager.cs | 4 ++-- .../view/Controls/DIYGrid/Settings/GridSettingsVM.cs | 6 ++++-- .../DIYGrid/Settings/SimpleGridSettingsManager.cs | 4 ++-- .../Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs | 8 +++++--- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs index 062e17c68..51596963c 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs @@ -186,7 +186,7 @@ namespace mbts.ui.controls { var gs = GridSettings.Default; _fallback_font_weight = gs.font_weight; _fallback_font_color = gs.font_color.rgb_color(); - _fallback_background_color = gs.background_color.value; + _fallback_background_color = gs.background_color.argb; _fallback_font_size = gs.font_size; _fallback_font_family = new FontFamily(gs.font_family); original_width = double.NaN; diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs index 8cf976235..bdf1e64f9 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs @@ -77,7 +77,7 @@ namespace mbts.ui { _font_size = backing(nameof(font_size), () => grid_settings.font_size, nameof(font_size)); _font_color = backing(nameof(font_color), () => grid_settings.font_color.rgb_solid_brush().frozen(), nameof(grid_settings)); _selection_highlight = backing(nameof(selection_highlight), () => grid_settings.selection_highlight.to_brush().frozen(), nameof(grid_settings)); - _background_color = backing(nameof(background_color), () => grid_settings.background_color.value?.rgb_color().rgb_solid_brush().frozen(), nameof(grid_settings)); + _background_color = backing(nameof(background_color), () => grid_settings.background_color.argb?.to_solid_brush().frozen(), nameof(grid_settings)); } public void Dispose() => @@ -114,7 +114,7 @@ namespace mbts.ui { var grid = value.general ?? GridSettings.Default; _grid_settings.set(grid); foreach (ColumnBase col in _columns) - col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.value); + col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.argb); _predicate_animations_data = value.predicate_animations; _animation_defs.clear(); foreach (var pa in _predicate_animations_data) { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs index 539c17e36..cd3bea93a 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs @@ -132,7 +132,9 @@ namespace mbts.spark { foreach (IGrouping g in animations) animation_map.AddOrUpdate(g.Key, p => animation_tuple(c: g), (p, t) => t.cell_animations.AddRange(g)); } - return _create_settings_obj(new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), col_settings, background_color: new NullableColorProto(background_color.color.rgb_color())), + return _create_settings_obj(new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), col_settings, + background_color: new NullableColorProto(background_color.color + .with((byte)(MathUtils.within_range(0, 1, background_color.opacity) * 255.0)))), animation_map.Select(kv => PredicateAnimations.create_data(kv.Key, kv.Value.cell_animations, kv.Value.row_animations, kv.Value.sounds))); // (List row_animations, List sounds, List cell_animations) animation_tuple(IEnumerable r = null, IEnumerable s = null, IGrouping c = null) => @@ -145,7 +147,7 @@ namespace mbts.spark { font_color.load_from(sd.general.font_color.rgb_solid_brush()); selection_highlight.load_from(sd.general.selection_highlight.to_brush()); if (sd.general.background_color.value.HasValue) { - background_color.load_from(sd.general.background_color.value.Value.to_solid_brush()); + background_color.load_from(sd.general.background_color.argb.Value.to_solid_brush()); } _font_size.set(sd.general.font_size); var col_animations = new Dictionary>>(); diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs index 0a002ac62..50a1cf7f7 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs @@ -35,7 +35,7 @@ namespace mbts.ui { _font_size = backing(nameof(font_size), () => grid_settings.font_size, nameof(font_size)); _font_color = backing(nameof(font_color), () => grid_settings.font_color.rgb_solid_brush().frozen(), nameof(grid_settings)); _selection_highlight = backing(nameof(selection_highlight), () => grid_settings.selection_highlight.to_brush().frozen(), nameof(grid_settings)); - _background_color = backing(nameof(background_color), () => grid_settings.background_color.value?.rgb_color().rgb_solid_brush().frozen(), nameof(grid_settings)); + _background_color = backing(nameof(background_color), () => grid_settings.background_color.argb?.to_solid_brush().frozen(), nameof(grid_settings)); _row_vms = row_vms; } @@ -88,7 +88,7 @@ namespace mbts.ui { grid = grid ?? GridSettings.Default; _grid_settings.set(grid); foreach (ColumnBase col in _columns) - col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.value); + col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.argb); // ** in the unfortunate event that we botch backwards compatability, and the columns don't bear a 1:1 relationship with the column-settings // don't add insult to injury by crashing ** if (grid_settings.columns != null) { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs index 5c01ac440..f5945e1bd 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs @@ -106,7 +106,9 @@ namespace mbts.spark { } public GridSettings create() => - new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), columns.Select(c => c.create()), background_color: new NullableColorProto(background_color.color.rgb_color())); + new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), columns.Select(c => c.create()), + background_color: new NullableColorProto(background_color.color + .with((byte)(MathUtils.within_range(0, 1, background_color.opacity) * 255.0)))); public void load_from(GridSettings value) { if (value == null) @@ -116,8 +118,8 @@ namespace mbts.spark { _font_weight.set(value.font_weight); font_color.load_from(value.font_color.rgb_solid_brush()); selection_highlight.load_from(value.selection_highlight.to_brush()); - if (value.background_color.value.HasValue) { - background_color.load_from(value.background_color.value.Value.to_solid_brush()); + if (value.background_color.argb.HasValue) { + background_color.load_from(value.background_color.argb.Value.to_solid_brush()); } _font_size.set(value.font_size); var curr_col_id = current_column?.id; From 5f6742f1dbe4d1d229aeb99cdb7321fce7d7d13c Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 16:48:08 -0500 Subject: [PATCH 18/44] adding enable_background_color to GridSettings and all the right spots --- .../Market/MarketView/MarketViewWindow.cs | 2 +- .../MarketView/MarketViewWindowFactory.cs | 6 +++-- .../Controls/DIYGrid/Settings/GridSettings.cs | 22 ++++++++++++++----- .../DIYGrid/Settings/SimpleGridSettingsVM.cs | 7 ++++-- .../Shell/Settings/ShellSettingsDialog.xaml | 4 ++-- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs index 35f22e89c..fe3520a6a 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs @@ -153,7 +153,7 @@ namespace mbts.spark { s => _vm.grid_settings_manager.create_vm( // we need to get the most up to date GridSettings when launching b/c users may // have changed some settings on the grid directly, like column widths. - s.with(_vm.columns.Select(c => c.create())) + s.with(_vm.columns.Select(c => c.create()), enable_background_color: true) ) ); vm.SubscribeDisposed(literal_title_source.OnDispatcher().Subscribe(t => vm.title = t)); diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs index 2d7b6e075..c28013d6b 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs @@ -74,6 +74,7 @@ namespace bts.shell { return null; } + // column upgrade var columns = s.columns.ToList(); var bid_col_index = columns.FindIndex(x => x.id == col_id(Columns.Bid)); var ask_col_index = columns.FindIndex(x => x.id == col_id(Columns.Ask)); @@ -85,11 +86,12 @@ namespace bts.shell { columns[ask_col_index] = columns[ask_col_index].with(background_color_override: new NullableColorProto(BTSColors.MarketData.ask.ToUint())); } } - return s.with(columns); + // and enable background color upgrade + return s.with(columns, enable_background_color: true); } - public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criterion); + public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criterion, enable_background_color: true); public IReadOnlyList sorting_criterion => _sorting_criteria ?? (_sorting_criteria = DefaultColumns.default_sorting_criterion.ToList()); diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs index 9e63e69d7..313fca866 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs @@ -21,7 +21,8 @@ namespace mbts.ui.settings { public static GridSettings Default => new GridSettings( selection_highlight: new ColorOpacityProto(FallbackValues.selection_highlight.Color, FallbackValues.selection_highlight.Opacity), - background_color: null);//new ColorOpacityProto(FallbackValues.background_color.Color, FallbackValues.background_color.Opacity)); + background_color: null, //new ColorOpacityProto(FallbackValues.background_color.Color, FallbackValues.background_color.Opacity)); + enable_background_color: false); // corrects any inappropriate values that would render the grid unusable (usually nulls) // NOTE: if you add a property to GridSettings that could have such a value, please add a conditional-correction for it below) @@ -70,6 +71,9 @@ namespace mbts.ui.settings { List _sorting_criterion; [ProtoMember(8)] readonly NullableColorProto _background_color; + [ProtoMember(9)] + [DefaultValue(false)] + readonly bool _enable_background_color; public GridSettings() { _font_family = _default_font_family; @@ -79,11 +83,12 @@ namespace mbts.ui.settings { // new setting in proto defaulted here _background_color = new NullableColorProto(); //new ColorOpacityProto(DIYGrid.DefaultBackgroundColor.Color, DIYGrid.DefaultBackgroundColor.Opacity); + _enable_background_color = false; } public GridSettings( string font_family = _default_font_family, double font_size = _default_font_size, FontWeight font_weight = default, uint font_color = _default_font_color, - ColorOpacityProto? selection_highlight = null, IEnumerable columns = null, IEnumerable sorting_criterion = null, NullableColorProto? background_color = null) { + ColorOpacityProto? selection_highlight = null, IEnumerable columns = null, IEnumerable sorting_criterion = null, NullableColorProto? background_color = null, bool enable_background_color = false) { // _font_family = font_family; _font_size = font_size; @@ -93,6 +98,7 @@ namespace mbts.ui.settings { _columns = new List(columns.empty_if_null()); _sorting_criterion = new List(sorting_criterion.empty_if_null()); _background_color = background_color ?? new NullableColorProto(); + _enable_background_color = enable_background_color; } public string font_family => _font_family; @@ -101,6 +107,7 @@ namespace mbts.ui.settings { public FontWeight font_weight => FontWeight.FromOpenTypeWeight(_font_weight); public ColorOpacityProto selection_highlight => _selection_highlight; public NullableColorProto background_color => _background_color; + public bool enable_background_color => _enable_background_color; public IReadOnlyList columns => _columns ?? (_columns = new List(0)); [Obsolete] // TODO: remove sorting_criterion from GridSettings entirely. This should be part of IShellWindow's StartupData, since it is an instance-specific setting, and prob not part of the shared defaults public IReadOnlyList sorting_criterion => _sorting_criterion ?? (_sorting_criterion = new List(0)); @@ -109,7 +116,7 @@ namespace mbts.ui.settings { new GridSettings(_default_font_family, _default_font_size, FontWeights.Normal, _default_font_color, new ColorOpacityProto(DIYGrid.DefaultSelectionHighlight.Color, DIYGrid.DefaultSelectionHighlight.Opacity), background_color: new NullableColorProto()); - public GridSettings with(IEnumerable columns = null, IEnumerable sorting_criterion = null, string font_family = null, double font_size = double.NaN) => + public GridSettings with(IEnumerable columns = null, IEnumerable sorting_criterion = null, string font_family = null, double font_size = double.NaN, bool? enable_background_color = null) => new GridSettings( font_family ?? _font_family, DoubleHelper.IsNaNOrInfinityOr(font_size, 0) ? _font_size : font_size, @@ -118,7 +125,8 @@ namespace mbts.ui.settings { _selection_highlight, columns ?? _columns, sorting_criterion ?? _sorting_criterion, - _background_color); + _background_color, + enable_background_color ?? _enable_background_color); public GridSettings clone() => with(); @@ -133,7 +141,8 @@ namespace mbts.ui.settings { #pragma warning disable CS0612 // Type or member is obsolete EqualityComparer.safe_sequence_equals(sorting_criterion, other.sorting_criterion) && #pragma warning restore CS0612 // Type or member is obsolete - background_color == other.background_color; + background_color == other.background_color && + enable_background_color == other.enable_background_color; public override bool Equals(object obj) => Equals(obj as GridSettings); @@ -149,6 +158,7 @@ namespace mbts.ui.settings { #pragma warning disable CS0612 // Type or member is obsolete EqualityComparer.safe_aggregate_hash(sorting_criterion), #pragma warning restore CS0612 // Type or member is obsolete - background_color.GetHashCode()); + background_color.GetHashCode(), + enable_background_color.GetHashCode()); } } \ No newline at end of file diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs index f5945e1bd..89ebfe4b6 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs @@ -37,7 +37,7 @@ namespace mbts.spark { readonly Property _font_weight; readonly Property _font_display_name; readonly Property _font_size; - readonly Property _show_predicate_animations, _show_cell_predicate_animations; + readonly Property _show_predicate_animations, _show_cell_predicate_animations, _show_background_color; readonly DeferrableActionWrapper _update; readonly IReadOnlyDictionary _column_flags; @@ -49,6 +49,7 @@ namespace mbts.spark { _font_display_name = backing(nameof(font_display_name), () => TextUtils.display_name(font_family, font_size), new[] { nameof(font_family), nameof(font_size) }); _show_predicate_animations = backing(nameof(show_predicate_animations), true); _show_cell_predicate_animations = backing(nameof(show_cell_predicate_animations), true); + _show_background_color = backing(nameof(show_background_color), false); _current_column = backing(nameof(current_column)); // update _update = new DeferrableActionWrapper(() => result_changed?.Invoke()); @@ -81,6 +82,7 @@ namespace mbts.spark { public ColorPickerPopupVM font_color { get; } = new ColorPickerPopupVM(); public ColorPickerPopupVM selection_highlight { get; } = new ColorPickerPopupVM(); public ColorPickerPopupVM background_color { get; } = new ColorPickerPopupVM(); + public bool show_background_color => _show_background_color.Value; public double font_size { get => _font_size.Value; set => _font_size.set(value); } public bool enable_sound_triggers => false; public bool show_predicate_animations { get => _show_predicate_animations.Value; set => _show_predicate_animations.set(value); } @@ -118,7 +120,8 @@ namespace mbts.spark { _font_weight.set(value.font_weight); font_color.load_from(value.font_color.rgb_solid_brush()); selection_highlight.load_from(value.selection_highlight.to_brush()); - if (value.background_color.argb.HasValue) { + _show_background_color.set(value.enable_background_color); + if (value.enable_background_color && value.background_color.argb.HasValue) { background_color.load_from(value.background_color.argb.Value.to_solid_brush()); } _font_size.set(value.font_size); diff --git a/src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml b/src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml index 882871751..c8d62d7c5 100644 --- a/src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml +++ b/src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml @@ -71,8 +71,8 @@ Font Color (default) - Background Color (default) - + Background Color (default) + Selection Highlight From 5c9c75463cffc9013e8cac331040d95fe7d31132 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 17:39:03 -0500 Subject: [PATCH 19/44] GridSettings background_color should be a uint (can be tranparent by deafult), and not a NullableColorProto; fml --- .../view/Controls/DIYGrid/Columns/ColumnBase.cs | 6 +++--- .../Controls/DIYGrid/Settings/GridSettings.cs | 15 ++++++++------- .../DIYGrid/Settings/GridSettingsManager.cs | 4 ++-- .../Controls/DIYGrid/Settings/GridSettingsVM.cs | 7 +++---- .../DIYGrid/Settings/SimpleGridSettingsManager.cs | 4 ++-- .../DIYGrid/Settings/SimpleGridSettingsVM.cs | 7 +++---- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs index 51596963c..4bd11dffd 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs @@ -174,7 +174,7 @@ namespace mbts.ui.controls { //readonly ExternalProperty _font_weigh FontWeight _fallback_font_weight; Color _fallback_font_color; - Color? _fallback_background_color; + Color _fallback_background_color; double _fallback_font_size; FontFamily _fallback_font_family; FontWeight? _font_weight_override; @@ -186,7 +186,7 @@ namespace mbts.ui.controls { var gs = GridSettings.Default; _fallback_font_weight = gs.font_weight; _fallback_font_color = gs.font_color.rgb_color(); - _fallback_background_color = gs.background_color.argb; + _fallback_background_color = gs.background_color.argb_color(); _fallback_font_size = gs.font_size; _fallback_font_family = new FontFamily(gs.font_family); original_width = double.NaN; @@ -263,7 +263,7 @@ namespace mbts.ui.controls { } // 'fallback' font-params (aka 'grid-level' font-params) - public void set_fallback_font_params(FontFamily font_family, double font_size, Color font_color, FontWeight font_weight, Color? background_color) { + public void set_fallback_font_params(FontFamily font_family, double font_size, Color font_color, FontWeight font_weight, Color background_color) { using (ReflectionHelper.detect_property_changes(this, _raise_prop_changed, nameof(font_family), nameof(font_size), nameof(font_color), nameof(font_weight), nameof(background_color), nameof(background_brush))) { _fallback_font_family = font_family; _fallback_font_size = font_size; diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs index 313fca866..8459ba17d 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs @@ -17,11 +17,12 @@ namespace mbts.ui.settings { const double _default_font_size = 11; const uint _default_font_color = 0; const ushort _default_font_weight = 400; + const uint _default_background_color = 0x00FFFFFF; // Colors.Transparent public static GridSettings Default => new GridSettings( selection_highlight: new ColorOpacityProto(FallbackValues.selection_highlight.Color, FallbackValues.selection_highlight.Opacity), - background_color: null, //new ColorOpacityProto(FallbackValues.background_color.Color, FallbackValues.background_color.Opacity)); + background_color: _default_background_color, //new ColorOpacityProto(FallbackValues.background_color.Color, FallbackValues.background_color.Opacity)); enable_background_color: false); // corrects any inappropriate values that would render the grid unusable (usually nulls) @@ -70,7 +71,7 @@ namespace mbts.ui.settings { [ProtoMember(7)] List _sorting_criterion; [ProtoMember(8)] - readonly NullableColorProto _background_color; + readonly uint _background_color; [ProtoMember(9)] [DefaultValue(false)] readonly bool _enable_background_color; @@ -82,13 +83,13 @@ namespace mbts.ui.settings { _font_color = _default_font_color; // new setting in proto defaulted here - _background_color = new NullableColorProto(); //new ColorOpacityProto(DIYGrid.DefaultBackgroundColor.Color, DIYGrid.DefaultBackgroundColor.Opacity); + _background_color = _default_background_color; _enable_background_color = false; } public GridSettings( string font_family = _default_font_family, double font_size = _default_font_size, FontWeight font_weight = default, uint font_color = _default_font_color, - ColorOpacityProto? selection_highlight = null, IEnumerable columns = null, IEnumerable sorting_criterion = null, NullableColorProto? background_color = null, bool enable_background_color = false) { + ColorOpacityProto? selection_highlight = null, IEnumerable columns = null, IEnumerable sorting_criterion = null, uint background_color = 0, bool enable_background_color = false) { // _font_family = font_family; _font_size = font_size; @@ -97,7 +98,7 @@ namespace mbts.ui.settings { _selection_highlight = selection_highlight ?? new ColorOpacityProto(0, 1); _columns = new List(columns.empty_if_null()); _sorting_criterion = new List(sorting_criterion.empty_if_null()); - _background_color = background_color ?? new NullableColorProto(); + _background_color = background_color; _enable_background_color = enable_background_color; } @@ -106,7 +107,7 @@ namespace mbts.ui.settings { public uint font_color => _font_color; public FontWeight font_weight => FontWeight.FromOpenTypeWeight(_font_weight); public ColorOpacityProto selection_highlight => _selection_highlight; - public NullableColorProto background_color => _background_color; + public uint background_color => _background_color; public bool enable_background_color => _enable_background_color; public IReadOnlyList columns => _columns ?? (_columns = new List(0)); [Obsolete] // TODO: remove sorting_criterion from GridSettings entirely. This should be part of IShellWindow's StartupData, since it is an instance-specific setting, and prob not part of the shared defaults @@ -114,7 +115,7 @@ namespace mbts.ui.settings { public static GridSettings get_default() => new GridSettings(_default_font_family, _default_font_size, FontWeights.Normal, _default_font_color, new ColorOpacityProto(DIYGrid.DefaultSelectionHighlight.Color, DIYGrid.DefaultSelectionHighlight.Opacity), - background_color: new NullableColorProto()); + background_color: _default_background_color); public GridSettings with(IEnumerable columns = null, IEnumerable sorting_criterion = null, string font_family = null, double font_size = double.NaN, bool? enable_background_color = null) => new GridSettings( diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs index bdf1e64f9..a006995f0 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs @@ -77,7 +77,7 @@ namespace mbts.ui { _font_size = backing(nameof(font_size), () => grid_settings.font_size, nameof(font_size)); _font_color = backing(nameof(font_color), () => grid_settings.font_color.rgb_solid_brush().frozen(), nameof(grid_settings)); _selection_highlight = backing(nameof(selection_highlight), () => grid_settings.selection_highlight.to_brush().frozen(), nameof(grid_settings)); - _background_color = backing(nameof(background_color), () => grid_settings.background_color.argb?.to_solid_brush().frozen(), nameof(grid_settings)); + _background_color = backing(nameof(background_color), () => grid_settings.background_color.argb_color().to_solid_brush().frozen(), nameof(grid_settings)); } public void Dispose() => @@ -114,7 +114,7 @@ namespace mbts.ui { var grid = value.general ?? GridSettings.Default; _grid_settings.set(grid); foreach (ColumnBase col in _columns) - col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.argb); + col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.argb_color()); _predicate_animations_data = value.predicate_animations; _animation_defs.clear(); foreach (var pa in _predicate_animations_data) { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs index cd3bea93a..38ae73a25 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs @@ -133,8 +133,7 @@ namespace mbts.spark { animation_map.AddOrUpdate(g.Key, p => animation_tuple(c: g), (p, t) => t.cell_animations.AddRange(g)); } return _create_settings_obj(new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), col_settings, - background_color: new NullableColorProto(background_color.color - .with((byte)(MathUtils.within_range(0, 1, background_color.opacity) * 255.0)))), + background_color: background_color.color.with((byte)(MathUtils.within_range(0, 1, background_color.opacity) * 255.0)).rgb_color()), animation_map.Select(kv => PredicateAnimations.create_data(kv.Key, kv.Value.cell_animations, kv.Value.row_animations, kv.Value.sounds))); // (List row_animations, List sounds, List cell_animations) animation_tuple(IEnumerable r = null, IEnumerable s = null, IGrouping c = null) => @@ -146,8 +145,8 @@ namespace mbts.spark { _font_weight.set(sd.general.font_weight); font_color.load_from(sd.general.font_color.rgb_solid_brush()); selection_highlight.load_from(sd.general.selection_highlight.to_brush()); - if (sd.general.background_color.value.HasValue) { - background_color.load_from(sd.general.background_color.argb.Value.to_solid_brush()); + if (sd.general.enable_background_color) { + background_color.load_from(sd.general.background_color.argb_color().to_solid_brush()); } _font_size.set(sd.general.font_size); var col_animations = new Dictionary>>(); diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs index 50a1cf7f7..d29df539d 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs @@ -35,7 +35,7 @@ namespace mbts.ui { _font_size = backing(nameof(font_size), () => grid_settings.font_size, nameof(font_size)); _font_color = backing(nameof(font_color), () => grid_settings.font_color.rgb_solid_brush().frozen(), nameof(grid_settings)); _selection_highlight = backing(nameof(selection_highlight), () => grid_settings.selection_highlight.to_brush().frozen(), nameof(grid_settings)); - _background_color = backing(nameof(background_color), () => grid_settings.background_color.argb?.to_solid_brush().frozen(), nameof(grid_settings)); + _background_color = backing(nameof(background_color), () => grid_settings.background_color.argb_color().to_solid_brush().frozen(), nameof(grid_settings)); _row_vms = row_vms; } @@ -88,7 +88,7 @@ namespace mbts.ui { grid = grid ?? GridSettings.Default; _grid_settings.set(grid); foreach (ColumnBase col in _columns) - col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.argb); + col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.argb_color()); // ** in the unfortunate event that we botch backwards compatability, and the columns don't bear a 1:1 relationship with the column-settings // don't add insult to injury by crashing ** if (grid_settings.columns != null) { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs index 89ebfe4b6..0ff2b120c 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs @@ -109,8 +109,7 @@ namespace mbts.spark { public GridSettings create() => new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), columns.Select(c => c.create()), - background_color: new NullableColorProto(background_color.color - .with((byte)(MathUtils.within_range(0, 1, background_color.opacity) * 255.0)))); + background_color: background_color.color.with((byte)(MathUtils.within_range(0, 1, background_color.opacity) * 255.0)).rgb_color()); public void load_from(GridSettings value) { if (value == null) @@ -121,8 +120,8 @@ namespace mbts.spark { font_color.load_from(value.font_color.rgb_solid_brush()); selection_highlight.load_from(value.selection_highlight.to_brush()); _show_background_color.set(value.enable_background_color); - if (value.enable_background_color && value.background_color.argb.HasValue) { - background_color.load_from(value.background_color.argb.Value.to_solid_brush()); + if (value.enable_background_color) { + background_color.load_from(value.background_color.argb_color().to_solid_brush()); } _font_size.set(value.font_size); var curr_col_id = current_column?.id; From 6603e8ad86c5e722a438df6ea1affbc78119a1c4 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 08:37:44 -0500 Subject: [PATCH 20/44] another sanitization spot --- src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs index fe3520a6a..da46e6c8d 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs @@ -153,7 +153,7 @@ namespace mbts.spark { s => _vm.grid_settings_manager.create_vm( // we need to get the most up to date GridSettings when launching b/c users may // have changed some settings on the grid directly, like column widths. - s.with(_vm.columns.Select(c => c.create()), enable_background_color: true) + MarketViewWindowFactory.StartupData.sanitize(s).with(_vm.columns.Select(c => c.create())) ) ); vm.SubscribeDisposed(literal_title_source.OnDispatcher().Subscribe(t => vm.title = t)); From 0d4f97a02383fb19ba01fe8a9d5223f52ab01407 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 09:11:47 -0500 Subject: [PATCH 21/44] visiblity of bg color Column-level override UI is now linked to GridSettings enable_background_color as well --- .../DIYGrid/Settings/GridSettingsView.xaml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml index e525965b0..35a5ca3b9 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml @@ -674,14 +674,16 @@ Visibility="{Binding DataContext.current_column.is_font_color_overridden, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource AncestorType=usp:GridSettingsView}}" /> - Override Background Color - - + Override Background Color + + + + From d59f7a5bb1b70857cb797e90e273f53c99839b78 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 10:32:32 -0500 Subject: [PATCH 22/44] new alpha-compliant ColorPickerPopupVM from John --- .../ColorPicker/ColorPickerPopup.xaml.cs | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/client/spark/view/Controls/ColorPicker/ColorPickerPopup.xaml.cs b/src/client/spark/view/Controls/ColorPicker/ColorPickerPopup.xaml.cs index e893b053c..a55734853 100644 --- a/src/client/spark/view/Controls/ColorPicker/ColorPickerPopup.xaml.cs +++ b/src/client/spark/view/Controls/ColorPicker/ColorPickerPopup.xaml.cs @@ -1,7 +1,9 @@ using bts.proto; +using bts.utils; using mbts.spark; using mbts.ui.controls.color_picker; using mbts.ui.shell; +using System; using System.Collections.ObjectModel; using System.Linq; using System.Windows; @@ -38,16 +40,42 @@ namespace mbts.ui.controls { class ColorPickerPopupVM : ViewModelBase, IValueFactory { readonly Property _color; readonly Property _opacity; + ObservableCollection _palettes; + bool _bind_opacity_to_alpha; + IDisposable _opacity_alpha_binding; public ColorPickerPopupVM() { _color = backing(nameof(color), Colors.Black); _opacity = backing(nameof(opacity), 1.0); - palettes = new ObservableCollection(ColorPalette.all_presets().Select(p => new ColorPaletteVM(p))); } public Color color { get => _color.Value; set => _color.set(value); } public double opacity { get => _opacity.Value; set => _opacity.set(value); } - public ObservableCollection palettes { get; } + public ObservableCollection palettes => _palettes ?? (_palettes = new ObservableCollection(ColorPalette.all_presets().Select(p => new ColorPaletteVM(p)))); + public bool bind_opacity_to_alpha { + get => _bind_opacity_to_alpha; + set { + if (_bind_opacity_to_alpha != value) { + Disposable.dispose(ref _opacity_alpha_binding); + _bind_opacity_to_alpha = value; + if (value) { + _opacity.Changed += opacity_changed; + _color.Changed += color_changed; + color_changed(default, color); + void opacity_changed(double oldval, double newval) { + _color.Changed -= color_changed; + _color.set(color.with((byte)(MathUtils.within_range(0, 1, newval) * 255.0))); + _color.Changed += color_changed; + } + void color_changed(Color oldval, Color newval) { + _opacity.Changed -= opacity_changed; + _opacity.set(newval.A / 255.0); + _opacity.Changed += opacity_changed; + } + } + } + } + } public SolidColorBrush create() => new SolidColorBrush(color) { Opacity = opacity }.frozen(); public void load_from(SolidColorBrush brush) { From c222181730231221ae5c4f700b5a68a25184581c Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 10:33:42 -0500 Subject: [PATCH 23/44] ColorOpacityProto can now spit out a Color with the appropriate alpha bytes --- src/client/spark/core/data/Proto/ColorOpacityProto.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/spark/core/data/Proto/ColorOpacityProto.cs b/src/client/spark/core/data/Proto/ColorOpacityProto.cs index c67e51d37..b5d69b2d6 100644 --- a/src/client/spark/core/data/Proto/ColorOpacityProto.cs +++ b/src/client/spark/core/data/Proto/ColorOpacityProto.cs @@ -22,6 +22,7 @@ namespace bts.proto { } public Color color => _color.rgb_color(); + public Color argb_color => Color.FromArgb((byte)(MathUtils.within_range(0, 1, _opacity) * 255.0), color.R, color.G, color.B); public double opacity => _opacity; public ColorOpacityProto with(uint? color = null, double? opacity = null) => From 14f2ae481a0ef029640381e97f33472ebcdce7a4 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 10:34:31 -0500 Subject: [PATCH 24/44] selection highlight and background color picker popupsnow make use of the new alpha hotness --- .../Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs index 0ff2b120c..9bb6232ca 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs @@ -80,8 +80,8 @@ namespace mbts.spark { public FontFamily font_family { get => _font_family.Value; set => _font_family.set(value); } public FontWeight font_weight { get => _font_weight.Value; set => _font_weight.set(value); } public ColorPickerPopupVM font_color { get; } = new ColorPickerPopupVM(); - public ColorPickerPopupVM selection_highlight { get; } = new ColorPickerPopupVM(); - public ColorPickerPopupVM background_color { get; } = new ColorPickerPopupVM(); + public ColorPickerPopupVM selection_highlight { get; } = new ColorPickerPopupVM(){ bind_opacity_to_alpha = true }; + public ColorPickerPopupVM background_color { get; } = new ColorPickerPopupVM() { bind_opacity_to_alpha = true }; public bool show_background_color => _show_background_color.Value; public double font_size { get => _font_size.Value; set => _font_size.set(value); } public bool enable_sound_triggers => false; @@ -118,10 +118,10 @@ namespace mbts.spark { _font_family.set(new FontFamily(value.font_family)); _font_weight.set(value.font_weight); font_color.load_from(value.font_color.rgb_solid_brush()); - selection_highlight.load_from(value.selection_highlight.to_brush()); + selection_highlight.color = value.selection_highlight.argb_color; _show_background_color.set(value.enable_background_color); if (value.enable_background_color) { - background_color.load_from(value.background_color.argb_color().to_solid_brush()); + background_color.color = value.background_color.argb_color(); } _font_size.set(value.font_size); var curr_col_id = current_column?.id; From ad819dca681960d02173bbbb0e01291e4290e3df Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 13:27:04 -0500 Subject: [PATCH 25/44] can just use rgb_color() now that Popup is in alpha enabled mode --- .../view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs index 9bb6232ca..93b4c2552 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs @@ -109,7 +109,7 @@ namespace mbts.spark { public GridSettings create() => new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), columns.Select(c => c.create()), - background_color: background_color.color.with((byte)(MathUtils.within_range(0, 1, background_color.opacity) * 255.0)).rgb_color()); + background_color: background_color.color.rgb_color()); public void load_from(GridSettings value) { if (value == null) From 2e831aa90e93daa9f71a4bd197330174c7011ba9 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 13:27:29 -0500 Subject: [PATCH 26/44] fixing alpha in column-level background override --- .../view/Controls/DIYGrid/Settings/GridColumnSettings.cs | 4 ++-- .../view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs index 770e7e52c..5b1dc0184 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs @@ -94,7 +94,7 @@ namespace mbts.ui.settings { public HorizontalAlignment horizontal_alignment => _horizontal_alignment; public double horizontal_offset => _horizontal_offset; public string display_name => _display_name; - public Color? background_color_override => _background_color_override.value; + public Color? background_color_override => _background_color_override.argb; public GridColumnSettings with( string display_name = null, bool? is_visible = null, bool? is_collapsed = null, NullableFontWeightProto? font_weight_override = null, NullableColorProto? font_color_override = null, @@ -109,7 +109,7 @@ namespace mbts.ui.settings { width ?? this.width, horizontal_alignment ?? this.horizontal_alignment, horizontal_offset ?? this.horizontal_offset, - (background_color_override ?? _background_color_override).value); + (background_color_override ?? _background_color_override).argb); public bool Equals(GridColumnSettings other) => other != null && diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs index dcb799b83..0f59769b2 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs @@ -84,7 +84,7 @@ namespace mbts.spark { // background color override public bool can_override_background_color { get => _can_override_background_color; private set => Set(ref _can_override_background_color, value); } public bool is_background_color_overridden { get => _is_background_color_overridden; set => Set(ref _is_background_color_overridden, value); } - public ColorPickerPopupVM background_color_override { get; } = new ColorPickerPopupVM(); + public ColorPickerPopupVM background_color_override { get; } = new ColorPickerPopupVM() { bind_opacity_to_alpha = true }; // animations public ObservableEditableCollection predicate_animations { get; } @@ -123,10 +123,7 @@ namespace mbts.spark { // background color is_background_color_overridden = _settings.background_color_override.HasValue; if (is_background_color_overridden) { - background_color_override.load_from( - new SolidColorBrush(_settings.background_color_override.Value) { - //Opacity = _settings.background_color_override.Value.opacity - }); + background_color_override.color = _settings.background_color_override.Value; } predicate_animations.SetItems(value.animations.empty_if_null().Select(g => { var vm = new PredicateCellAnimationVM(id, owner._create_column_predicate_vm(id), owner._predicate_data_factory); From 6b97d559275a1cbbcbb61c8d5b8641f145a0d209 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 14:09:47 -0500 Subject: [PATCH 27/44] adding show_background_color to main GridSettingsVM so that OB bg color settings are kept hidden for now; misc comment --- .../view/Controls/DIYGrid/Settings/GridSettingsVM.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs index 38ae73a25..0d575483f 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs @@ -57,7 +57,7 @@ namespace mbts.spark { readonly Property _font_weight; readonly Property _font_display_name; readonly Property _font_size; - readonly Property _show_predicate_animations, _show_cell_predicate_animations; + readonly Property _show_predicate_animations, _show_cell_predicate_animations, _show_background_color; readonly OrdersModel _orders_model; readonly IReadOnlyDictionary _column_flags; @@ -84,6 +84,7 @@ namespace mbts.spark { _font_display_name = backing(nameof(font_display_name), () => TextUtils.display_name(font_family, font_size), new[] { nameof(font_family), nameof(font_size) }); _show_predicate_animations = backing(nameof(show_predicate_animations), true); _show_cell_predicate_animations = backing(nameof(show_cell_predicate_animations), true); + _show_background_color = backing(nameof(show_background_color), false); _current_column = backing(nameof(current_column)); predicate_animations = new ObservableEditableCollection(() => new PredicateRowAnimationVM(_create_predicate_vm(), _predicate_data_factory), true); @@ -102,6 +103,7 @@ namespace mbts.spark { public ColorPickerPopupVM font_color { get; } = new ColorPickerPopupVM(); public ColorPickerPopupVM selection_highlight { get; } = new ColorPickerPopupVM(); public ColorPickerPopupVM background_color { get; } = new ColorPickerPopupVM(); + public bool show_background_color => _show_background_color.Value; public double font_size { get => _font_size.Value; set => _font_size.set(value); } public bool enable_sound_triggers => true; public bool show_predicate_animations { get => _show_predicate_animations.Value; set => _show_predicate_animations.set(value); } @@ -145,7 +147,12 @@ namespace mbts.spark { _font_weight.set(sd.general.font_weight); font_color.load_from(sd.general.font_color.rgb_solid_brush()); selection_highlight.load_from(sd.general.selection_highlight.to_brush()); + _show_background_color.set(sd.general.enable_background_color); if (sd.general.enable_background_color) { + // note that when the OB is moved to allow background colors + // we can just background_color.color instead of load_from + // so that we get all the alpha goodness similar to SimpleGridSettingsVM + // assuming bind_opacity_to_alpha on the picker. background_color.load_from(sd.general.background_color.argb_color().to_solid_brush()); } _font_size.set(sd.general.font_size); From 0a1cf0198df888bccc18da68c9c4368e8097e25d Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 14:20:59 -0500 Subject: [PATCH 28/44] sending my NullableColorOpacityProto to /dev/null --- .../data/Proto/NullableColorOpacityProto.cs | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 src/client/spark/core/data/Proto/NullableColorOpacityProto.cs diff --git a/src/client/spark/core/data/Proto/NullableColorOpacityProto.cs b/src/client/spark/core/data/Proto/NullableColorOpacityProto.cs deleted file mode 100644 index 77344d6a3..000000000 --- a/src/client/spark/core/data/Proto/NullableColorOpacityProto.cs +++ /dev/null @@ -1,45 +0,0 @@ -using bts.utils; -using mbts.ui; -using mbts.utils; -using ProtoBuf; -using System; -using System.Windows.Media; - -namespace bts.proto { - [ProtoContract] - struct NullableColorOpacityProto : IEquatable { - [ProtoMember(1)] - readonly uint? _color; - [ProtoMember(2)] - readonly double? _opacity; - - public NullableColorOpacityProto(ColorOpacityProto? cop = default) { - _color = cop?.color.rgb_color(); - _opacity = cop?.opacity; - } - - public ColorOpacityProto? value { - get { - if (_color.HasValue && _opacity.HasValue) - return new ColorOpacityProto(_color.Value, _opacity.Value); - return null; - } - } - - public bool Equals(NullableColorOpacityProto other) => - EqualityComparer.nullable_equals(_color, other._color) && - EqualityComparer.nullable_equals(_opacity, other._opacity); - - public override bool Equals(object obj) => - obj is NullableColorProto ncp && Equals(ncp); - - public override int GetHashCode() { - uint c = _color.HasValue ? _color.Value : 0; - double o = _opacity.HasValue ? _opacity.Value : 0; - return EqualityComparer.aggregate_hash(c, o); - } - - public static bool operator ==(NullableColorOpacityProto a, NullableColorOpacityProto b) => a.Equals(b); - public static bool operator !=(NullableColorOpacityProto a, NullableColorOpacityProto b) => !a.Equals(b); - } -} \ No newline at end of file From c4866253b86b83d8b506bbee230eb6669ee31d57 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 15:14:33 -0500 Subject: [PATCH 29/44] need a KeyUp here --- .../spark/view/Extensions/UIElementExtensions.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/client/spark/view/Extensions/UIElementExtensions.cs b/src/client/spark/view/Extensions/UIElementExtensions.cs index 1a338ed9f..cc3e67da3 100644 --- a/src/client/spark/view/Extensions/UIElementExtensions.cs +++ b/src/client/spark/view/Extensions/UIElementExtensions.cs @@ -156,6 +156,19 @@ namespace mbts.ui.extensions { } } + public static IDisposable SubscribePreviewKeyUp(this UIElement target, KeyEventHandler callback) { + target.PreviewKeyUp += callback; + return Disposable.Create(() => target.PreviewKeyUp -= callback); + } + + public static IDisposable SubscribePreviewKeyUp(this UIElement target, Key key, Action callback) { + return SubscribePreviewKeyUp(target, on_preview_key_up); + void on_preview_key_up(object sender, KeyEventArgs e) { + if (e.Key == key) + callback(); + } + } + public static IObservable SubscribePreviewKeyDown(this UIElement target) => Observable.Create(o => { target.PreviewKeyDown += on_preview_key_down; From fe179d44f2019d264264166d0d75b9d0c986715d Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 15:15:07 -0500 Subject: [PATCH 30/44] RowSelectionAdorner now responds to KeyUp (CTRL-A for example) --- src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs index c7625c654..7e59c46e0 100644 --- a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs +++ b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs @@ -58,6 +58,8 @@ namespace mbts.ui.controls.adorners { _disposables.Add(_diy_rp.SubscribePreviewMouseDown((s, e) => InvalidateVisual())); // the main event _disposables.Add(_diy_rp.SubscribePreviewMouseUp((s, e) => InvalidateVisual())); + // so that we update for potential mass keyboard combinations (CTRL-A) + _disposables.Add(_diy_rp.SubscribePreviewKeyUp((s, e) => InvalidateVisual())); // so that we update the highlight as the grid scrolls _disposables.Add(_diy_scroll.SubscribeScrollChanged((s, e) => InvalidateVisual())); } From ec4f88c68fe25711edea01d9fb5dd015be693a5d Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 15:48:59 -0500 Subject: [PATCH 31/44] having row selection adorner reactor to selection changed events rather than key|mouse up|down --- .../spark/view/Controls/Adorners/RowSelectionAdorner.cs | 8 ++------ src/client/spark/view/Extensions/UIElementExtensions.cs | 7 +++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs index 7e59c46e0..688be814d 100644 --- a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs +++ b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs @@ -54,12 +54,8 @@ namespace mbts.ui.controls.adorners { _diy_scroll = scroll_viewer; _diy_scp = _diy_rp.descendants_of_type().empty_if_null().FirstOrDefault(); - // so that we clear out any previously selected highlighted rows - _disposables.Add(_diy_rp.SubscribePreviewMouseDown((s, e) => InvalidateVisual())); - // the main event - _disposables.Add(_diy_rp.SubscribePreviewMouseUp((s, e) => InvalidateVisual())); - // so that we update for potential mass keyboard combinations (CTRL-A) - _disposables.Add(_diy_rp.SubscribePreviewKeyUp((s, e) => InvalidateVisual())); + // We actually don't need mouse up/down or key up/down when we can just respond to selection changes + _disposables.Add(((System.Windows.Controls.Primitives.Selector)_diy_rp).SubscribeSelectionChanged((s, e) => InvalidateVisual())); // so that we update the highlight as the grid scrolls _disposables.Add(_diy_scroll.SubscribeScrollChanged((s, e) => InvalidateVisual())); } diff --git a/src/client/spark/view/Extensions/UIElementExtensions.cs b/src/client/spark/view/Extensions/UIElementExtensions.cs index cc3e67da3..4a1096d23 100644 --- a/src/client/spark/view/Extensions/UIElementExtensions.cs +++ b/src/client/spark/view/Extensions/UIElementExtensions.cs @@ -210,6 +210,13 @@ namespace mbts.ui.extensions { } } + public static class SelectorExtensions { + public static IDisposable SubscribeSelectionChanged(this System.Windows.Controls.Primitives.Selector target, SelectionChangedEventHandler callback) { + target.SelectionChanged += callback; + return Disposable.Create(() => target.SelectionChanged -= callback); + } + } + public static class ScrollViewerExtensions { public static IDisposable SubscribeScrollChanged(this ScrollViewer target, ScrollChangedEventHandler callback) { target.ScrollChanged += callback; From 5e0f1d450cb3d769bd1fc5a2a473315e98ebf4b5 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 15 Aug 2019 15:49:26 -0500 Subject: [PATCH 32/44] removing unused property --- src/client/spark/view/Controls/DIYGrid/DIYGrid.cs | 2 -- src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs | 1 - 2 files changed, 3 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs index bfab02f71..5cfc7ccbe 100644 --- a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs +++ b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs @@ -254,8 +254,6 @@ namespace mbts.ui.controls { // and FrameworkElementColumns that paint the selection brush themselves // (e.g MarketView bid/ask columns, bc their background is not transparent, it covers the ListBoxItem selection-highlight). public static readonly SolidColorBrush DefaultSelectionHighlight = new SolidColorBrush(Colors.MediumSlateBlue) { Opacity = 0.4 }; - // I have no idea why DefaultBackgroundColor needs to be frozen but DefaultSelectionHighlight is apparently fine as is - public static readonly SolidColorBrush DefaultBackgroundColor = null; //new SolidColorBrush(BTSColors.Grid.input_cell_background) { Opacity = 0.40 }.frozen(); public static readonly Pen DefaultSelectionStroke = new Pen(Brushes.MediumSlateBlue, 1); readonly NotifyCollectionChangedEventHandler _sort_descriptions_collection_changed_cb; double _inactive_selection_opacity = 0.2; diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs index 8459ba17d..c125d1368 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs @@ -43,7 +43,6 @@ namespace mbts.ui.settings { public static Color font_color => _default_font_color.rgb_color(); public static FontWeight font_weight => FontWeight.FromOpenTypeWeight(_default_font_weight); public static SolidColorBrush selection_highlight => DIYGrid.DefaultSelectionHighlight; - public static SolidColorBrush background_color => DIYGrid.DefaultBackgroundColor; } public static IValueConverter selection_highlight_converter => ValueConverter.create(gs => gs.selection_highlight.to_brush().frozen()); From 4ea32e06a90054ed2155ea13b7cfce3722d65954 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Mon, 26 Aug 2019 16:22:33 -0500 Subject: [PATCH 33/44] fix ActionMenu binding in SimpleGrid template (cherry picked from commit 3b25e181fa6ae0a6207d2cad53721ebfc264066f) --- src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml b/src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml index c8d62d7c5..694b13a4a 100644 --- a/src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml +++ b/src/client/spark/view/Shell/Settings/ShellSettingsDialog.xaml @@ -185,7 +185,7 @@ - + From 298f9261b4802826a8fcfa499e15cfc8b8b3602a Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 27 Aug 2019 14:49:43 -0500 Subject: [PATCH 34/44] allow overrideable settings to not be overridden --- .../Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs index 51f0f532e..250bcfc3d 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs @@ -55,8 +55,8 @@ namespace mbts.spark { 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, + can_override_font_weight ? (is_font_weight_overridden ? new NullableFontWeightProto(font_weight_override) : new NullableFontWeightProto()) : (NullableFontWeightProto?)null, + can_override_font_color ? (is_font_color_overridden ? new NullableColorProto(font_color_override.color) : new NullableColorProto()) : (NullableColorProto?)null, width, horizontal_alignment, background_color_override: is_background_color_overridden ? From e2d065f6b34f587d2b14c763cdafd6cd0768a164 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 27 Aug 2019 15:12:21 -0500 Subject: [PATCH 35/44] allow font color to change on bid/ask implied/direct/merged cols --- src/client/spark/Modules/Market/MarketView/MarketViewVM.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs index 9e67a4bb1..b8257083e 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs @@ -113,12 +113,6 @@ namespace mbts.spark { var col_settings_flags = new Dictionary { { Columns.Bid.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor | GridColumnSettingsFeatureFlags.ImmutableBackgroundColor }, { Columns.Ask.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor | GridColumnSettingsFeatureFlags.ImmutableBackgroundColor}, - { Columns.BidImpliedSize.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }, - { Columns.BidDirectSize.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }, - { Columns.BidMergedSize.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }, - { Columns.AskImpliedSize.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }, - { Columns.AskDirectSize.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }, - { Columns.AskMergedSize.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }, { Columns.WorkingAsks.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }, { Columns.WorkingBids.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor } }; From d52ec704fbccbfd923e08a4ce03fb2568150d24b Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 27 Aug 2019 15:14:49 -0500 Subject: [PATCH 36/44] bind Foreground to font_brush --- .../DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs b/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs index efeaa83b7..2b6b62bf0 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/HyperlinkColumn.cs @@ -24,7 +24,8 @@ namespace mbts.ui.controls { public Thickness padding { get; set; } = _default_padding; public override FrameworkElement view_factory() { - var hl = new HyperlinkCell { Foreground = font_brush, Padding = padding }; + var hl = new HyperlinkCell { Padding = padding }; + hl.SetBinding(HyperlinkCell.ForegroundProperty, new Binding(nameof(font_brush)) { Source = this }); hl.SetBinding(HyperlinkCell.TextProperty, _binding); hl.SetBinding(HyperlinkCell.FontFamilyProperty, new Binding(nameof(font_family)) { Source = this }); hl.SetBinding(HyperlinkCell.FontSizeProperty, new Binding(nameof(font_size)) { Source = this }); From b528e1c1ecf098d570e49efd8507b189d04ed6d8 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 27 Aug 2019 16:48:14 -0500 Subject: [PATCH 37/44] background color default should be transparent and not black --- .../spark/view/Controls/DIYGrid/Settings/GridSettings.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs index c125d1368..5afc8d146 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs @@ -43,6 +43,7 @@ namespace mbts.ui.settings { public static Color font_color => _default_font_color.rgb_color(); public static FontWeight font_weight => FontWeight.FromOpenTypeWeight(_default_font_weight); public static SolidColorBrush selection_highlight => DIYGrid.DefaultSelectionHighlight; + public static uint background_color => _default_background_color; } public static IValueConverter selection_highlight_converter => ValueConverter.create(gs => gs.selection_highlight.to_brush().frozen()); @@ -88,7 +89,7 @@ namespace mbts.ui.settings { public GridSettings( string font_family = _default_font_family, double font_size = _default_font_size, FontWeight font_weight = default, uint font_color = _default_font_color, - ColorOpacityProto? selection_highlight = null, IEnumerable columns = null, IEnumerable sorting_criterion = null, uint background_color = 0, bool enable_background_color = false) { + ColorOpacityProto? selection_highlight = null, IEnumerable columns = null, IEnumerable sorting_criterion = null, uint background_color = _default_background_color, bool enable_background_color = false) { // _font_family = font_family; _font_size = font_size; From f90ef6e12c87741a91ee996ab25c81ea5e65d0ab Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 27 Aug 2019 16:49:30 -0500 Subject: [PATCH 38/44] changing can we set the background color override to check for can_override_background_color --- .../Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs index 250bcfc3d..9c6ffa28b 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs @@ -59,8 +59,9 @@ namespace mbts.spark { can_override_font_color ? (is_font_color_overridden ? new NullableColorProto(font_color_override.color) : new NullableColorProto()) : (NullableColorProto?)null, width, horizontal_alignment, - background_color_override: is_background_color_overridden ? - new NullableColorProto(background_color_override.color) : default); + background_color_override: + can_override_background_color ? (is_background_color_overridden ? new NullableColorProto(background_color_override.color) : new NullableColorProto()) : (NullableColorProto ?)null + ); public void load_from(GridColumnSettings value) { _settings = value; From 20df8a6597af5f5fcbd39fafd9a9da5ca15ce052 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 27 Aug 2019 16:50:47 -0500 Subject: [PATCH 39/44] if show_background, then set the background from the color popup, else default to the Fallback background color, transparent --- .../view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs index 93b4c2552..e90fda0da 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs @@ -109,7 +109,7 @@ namespace mbts.spark { public GridSettings create() => new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), columns.Select(c => c.create()), - background_color: background_color.color.rgb_color()); + background_color: show_background_color ? background_color.color.rgb_color() : GridSettings.FallbackValues.background_color); public void load_from(GridSettings value) { if (value == null) From 08478a266374c95259d1d4da29005275a4397f2d Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 28 Aug 2019 08:01:23 -0500 Subject: [PATCH 40/44] don't skip new bool when serializing settings to disk --- .../Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs index e90fda0da..c6e0b48f5 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs @@ -107,9 +107,15 @@ namespace mbts.spark { } } + // Note that one of the responsibilites of create() is via instance_vm.get_result() in the ShellSettingsDialogVM.export_to_custom_cmd, + // which is what handles saving .grid files. This means if you have introduced any optional args, say for example enable_background_color + // that is not yet a feature of all windows at this point in time, 8/28/2019, you need to be sure it's explicity set if the proto + // constructor parameter default has been initialized to different default value. public GridSettings create() => - new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), columns.Select(c => c.create()), - background_color: show_background_color ? background_color.color.rgb_color() : GridSettings.FallbackValues.background_color); + new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), + columns.Select(c => c.create()), + background_color: show_background_color ? background_color.color.rgb_color() : GridSettings.FallbackValues.background_color, + enable_background_color: show_background_color); public void load_from(GridSettings value) { if (value == null) From 707b5cf01678d2c805629f1bdb0e8013bd5ec3a3 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 28 Aug 2019 11:03:25 -0500 Subject: [PATCH 41/44] PR suggestion - adding Flags to enum declaration --- .../spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs index 0f59769b2..66b8042e0 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs @@ -22,6 +22,7 @@ namespace mbts.spark { /// /// For flag behavior implementation, see /// + [Flags] enum GridColumnSettingsFeatureFlags { None = 0, ImmutableFontColor = 1, From aaf90c5293c908b7038ad93c2fa71b600f125c11 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 28 Aug 2019 11:42:09 -0500 Subject: [PATCH 42/44] PR feedback - Hardening the RowSelectionAdorner --- .../spark/view/Controls/Adorners/RowSelectionAdorner.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs index 688be814d..d1c1ef5f9 100644 --- a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs +++ b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs @@ -46,11 +46,11 @@ namespace mbts.ui.controls.adorners { } #endregion - public RowSelectionAdorner(FrameworkElement adorned_element, ScrollViewer scroll_viewer) : base(adorned_element) { + internal RowSelectionAdorner(DIYGridRowsPresenter adorned_element, ScrollViewer scroll_viewer) : base(adorned_element) { // we want our clicks to go through to the underlying grid IsHitTestVisible = false; - _diy_rp = (DIYGridRowsPresenter)adorned_element; + _diy_rp = adorned_element; _diy_scroll = scroll_viewer; _diy_scp = _diy_rp.descendants_of_type().empty_if_null().FirstOrDefault(); From d80045d7c05754b65c4645265811d7ca6bedecd6 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 28 Aug 2019 13:07:20 -0500 Subject: [PATCH 43/44] PR suggestion - adding new _default_enable_background_color const rather than having random falses strewn throughout; good style catch John --- .../spark/view/Controls/DIYGrid/Settings/GridSettings.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs index 5afc8d146..06ff9ab8e 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettings.cs @@ -18,12 +18,13 @@ namespace mbts.ui.settings { const uint _default_font_color = 0; const ushort _default_font_weight = 400; const uint _default_background_color = 0x00FFFFFF; // Colors.Transparent + const bool _default_enable_background_color = false; public static GridSettings Default => new GridSettings( selection_highlight: new ColorOpacityProto(FallbackValues.selection_highlight.Color, FallbackValues.selection_highlight.Opacity), background_color: _default_background_color, //new ColorOpacityProto(FallbackValues.background_color.Color, FallbackValues.background_color.Opacity)); - enable_background_color: false); + enable_background_color: _default_enable_background_color); // corrects any inappropriate values that would render the grid unusable (usually nulls) // NOTE: if you add a property to GridSettings that could have such a value, please add a conditional-correction for it below) @@ -84,12 +85,12 @@ namespace mbts.ui.settings { // new setting in proto defaulted here _background_color = _default_background_color; - _enable_background_color = false; + _enable_background_color = _default_enable_background_color; } public GridSettings( string font_family = _default_font_family, double font_size = _default_font_size, FontWeight font_weight = default, uint font_color = _default_font_color, - ColorOpacityProto? selection_highlight = null, IEnumerable columns = null, IEnumerable sorting_criterion = null, uint background_color = _default_background_color, bool enable_background_color = false) { + ColorOpacityProto? selection_highlight = null, IEnumerable columns = null, IEnumerable sorting_criterion = null, uint background_color = _default_background_color, bool enable_background_color = _default_enable_background_color) { // _font_family = font_family; _font_size = font_size; From 78be61c9baacc0f48dce99573627ea64a071b08a Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 28 Aug 2019 13:11:48 -0500 Subject: [PATCH 44/44] PR suggestion - changing ISelectionHighlightListener.on_selection_fill's parameter method to be SolidColorBrush so we avoid casting --- .../spark/view/Controls/Adorners/RowSelectionAdorner.cs | 7 +++---- .../spark/view/Controls/DIYGrid/Columns/ColumnBase.cs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs index d1c1ef5f9..e6079090d 100644 --- a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs +++ b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs @@ -85,10 +85,9 @@ namespace mbts.ui.controls.adorners { } } - public void on_selection_fill(Brush selection_fill) { - var selection_brush = (SolidColorBrush)selection_fill; - Fill = selection_brush; - Stroke = new Pen(selection_brush.Color.to_solid_brush(), 1); + public void on_selection_fill(SolidColorBrush selection_fill) { + Fill = selection_fill; + Stroke = new Pen(selection_fill.Color.to_solid_brush(), 1); InvalidateVisual(); } diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs index 4bd11dffd..4b4bc66df 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs @@ -166,7 +166,7 @@ namespace mbts.ui.controls { } public interface ISelectionHighlightListener { - void on_selection_fill(Brush selection_fill); + void on_selection_fill(SolidColorBrush selection_fill); } // To include extra data with your column type you are encouraged to derive from DIYGridColumn